Overview
Nuxt UI provides seamless dark mode support through the @nuxtjs/color-mode module, which is automatically installed and configured.Automatic Integration
The color mode module is automatically registered by Nuxt UI with optimized settings:Color mode is enabled by default. You can disable it by setting
colorMode: false in your Nuxt UI configuration.Using Color Mode
useColorMode Composable
Access and control the color mode in your components:Available Properties
colorMode.value- Current active mode ('light','dark', or'system')colorMode.preference- User’s preference (can be set to change mode)colorMode.forced- Force a specific mode
Color Mode Components
Nuxt UI provides ready-to-use components for color mode switching:ColorModeButton
A button that toggles between light and dark modes:ColorModeSwitch
A toggle switch for dark mode:ColorModeSelect
A dropdown to select from all available modes:- Light - Force light mode
- Dark - Force dark mode
- System - Follow system preference
Locale Support
Color mode components use the locale system for labels:Styling for Color Modes
Dark Mode Classes
Use thedark: variant in your Tailwind classes:
Semantic Color Tokens
Nuxt UI provides semantic color tokens that automatically adapt:bg-background/text-foreground- Base colorsbg-elevated- Elevated surfacetext-muted- Muted texttext-primary- Primary brand color
Using semantic tokens ensures your UI looks great in both light and dark modes without additional styling.
Custom Color Modes
Add custom color modes beyond light and dark:nuxt.config.ts
ColorModeImage and ColorModeAvatar
Display different images based on color mode:ColorModeImage
ColorModeAvatar
Disabling Transitions
By default, Nuxt UI disables transitions during color mode changes to prevent flashing:nuxt.config.ts
SSR Considerations
The color mode module handles SSR correctly:- Prevents flash of incorrect theme on page load
- Syncs with
localStoragefor persistence - Respects system preferences
Force Color Mode
Force a specific color mode for certain pages:Disabling Color Mode
If you don’t need color mode support, disable it:nuxt.config.ts
When disabled, Nuxt UI provides a stub
useColorMode composable that components like DashboardSearch can still use without errors.