Skip to main content
When you enable dark mode in your theme, the CLI generates your color tokens as CSS variables instead of hardcoded values. Light mode values load by default, and dark mode values activate when a dark class is present on the page. This guide covers how to toggle between them.

How the generated code works

The CLI syncs two files:
  • tailwind.config.js — references CSS variables instead of hardcoded values, with darkMode: 'selector' enabled
  • theme.css — defines :root variables for light mode and .dark overrides for dark mode
tailwind.config.js
theme.css
Import theme.css in your global stylesheet or entry point:
globals.css

Sync your theme

Run the CLI to sync your theme (including dark mode) to your codebase:

Add a toggle

To switch between light and dark mode, your app needs to toggle the dark class on the <html> element. Here’s how to set that up:
1

Install next-themes

2

Wrap your app in the ThemeProvider

app/layout.tsx
3

Add a toggle button

Last modified on May 5, 2026