Cursor prompt
Add Dark Mode with CSS Variables
Implement theme switching with CSS custom properties, localStorage persistence, system preference detection, and flash-free loading.
Add dark mode to {{project_name}} using CSS custom properties. ## Framework: {{framework}} ## Current Styling: {{styling}} ### Theme Token System Define all colors as CSS variables in :root (light) and [data-theme="dark"]: ```css :root { --color-bg: #ffffff; --color-surface: #f9fafb; --color-text: #111827; --color-text-muted: #6b7280; --color-border: #e5e7eb; --color-primary: #6366f1; --color-primary-hover: #4f46e5; } [data-theme="dark"] { --color-bg: #0f172a; --color-surface: #1e293b; --color-text: #f8fafc; --color-text-muted: #94a3b8; --color-border: #334155; --color-primary: #818cf8; --color-primary-hover: #6366f1; } ``` ### Theme Provider - Read from localStorage on mount; detect system preference as fallback - Apply by setting data-theme on <html> element - Listen for system preference changes via matchMedia - Expose: { theme, setTheme, toggleTheme } ### Flash Prevention (Critical — inline in <head>) ```html <script> const t = localStorage.getItem('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'); document.documentElement.setAttribute('data-theme', t); </script> ``` ### Theme Toggle Component Animated sun/moon icon with smooth transition, proper aria-label. ### Transition (no jarring switches) ```css * { transition: background-color 200ms, color 200ms, border-color 200ms; } ``` ### Output CSS token file, ThemeProvider, toggle component, flash-prevention script, Tailwind config update.
Fill in: {{project_name}}, {{framework}}, {{styling}}. In Loopy you fill these in a form and copy the finished prompt in one click.
More ui design prompts
- CursorAdd WCAG Accessibility to UIWCAG 2.1 AA compliance: keyboard navigation, ARIA labels, focus management, color contrast, and screen reader support.
- v0Analytics DashboardData visualization dashboard with KPI cards, charts, data table, and date range filtering.
- v0Blog LayoutClean blog with featured posts, category filters, reading time, and author profiles.
- CursorBuild Multi-Step Form WizardMulti-step wizard with per-step validation, progress indicator, back/next navigation, and sessionStorage persistence.
- v0Component from DescriptionStructured prompt to generate a polished React component with proper accessibility, responsiveness, and dark mode support.
- v0Component Library ShowcaseDesign system documentation page showing component variants, usage examples, and code snippets.

