Skip to main content

How dark mode works

next-themes manages the dark class on the <html> element. Tailwind’s darkMode: 'class' strategy reads this class to activate dark-mode variants. The user’s preference (light / dark / system) is stored in localStorage and restored on every page load. The theme toggle in the top navigation bar cycles through three states: Light → Dark → System. “System” follows the OS preference. When a user changes their theme, the change takes effect immediately with no flash of unstyled content (FOUC). next-themes injects a small blocking script before the page renders that reads localStorage and applies the correct class before the first paint.

The CSS variable system

All colors are defined as CSS custom properties in index.css. Tailwind uses these variables through its theme configuration. Every component uses semantic variable names, not hardcoded colors.
Tailwind maps these variables to utility classes via tailwind.config.ts:

Writing dark-mode-compatible components

Use semantic class names. The variable flips between light and dark values automatically — you do not write dark: variants for basic colors. Correct — semantic classes:
Incorrect — hardcoded colors:
The semantic classes and their meaning:

Customizing the brand color

To change the primary color from AspFox blue to your brand color:
  1. Update --primary and --ring in :root in index.css
  2. Update --primary and --ring in .dark in index.css
  3. Update the primary color values in tailwind.config.ts to match
The new color propagates to every component using bg-primary, text-primary, border-primary, ring-primary, or text-primary-foreground. No other changes are needed. Example — changing to green: