Dark Mode Implementation
A guide to implementing robust dark mode support with system preference detection, manual toggle, and smooth transitions.
Usage
Ask about dark mode implementation, color scheme design, theme switching, or preference persistence.
Examples
- "Add dark mode with system preference detection"
- "How do I create a theme toggle that persists across sessions?"
- "Design a color palette that works in both light and dark modes"
Guidelines
- Use CSS custom properties for all theme-dependent colors
- Respect prefers-color-scheme for initial theme selection
- Store user preference in localStorage for persistence
- Use color-scheme property for native form control styling
- Test contrast ratios in both themes for accessibility