export const title = "Dark mode"
export const description = "Easily swap between light and dark modes with CSS variables."
export const metaDescription = "Switch between light and dark mode effortlessly with CSS variables. Untitled UI React is the world's largest collection of open-source React components."
import { FeaturedCardEventCTA } from "@/components/application/app-navigation/base-components/featured-cards.demo";
import { DarkModeDemo } from "@/components/application/date-picker/date-picker.demo";
## Dark mode support
Untitled UI React components come with native dark mode support out-of-the-box, so there’s no need for separate styles.
```jsx
// [!code word:bg-gray-50 text-gray-900 dark\:bg-gray-950 dark\:text-gray-50]
Hello, world!
// [!code --]
// [!code word:bg-primary text-primary]
Hello, world!
// [!code ++]
```
Dark mode styles are managed via design tokens and CSS variables, not hardcoded in components. This keeps your styles consistent and easy to maintain.
## How to switch to dark mode
Switch to dark mode by adding the `dark-mode` class to any element. Everything inside that element renders in dark mode, so you can have a dark section on an otherwise light page. Only the `dark-mode` class is defined; there is no `light-mode` class, so a light island nested inside a dark container needs its own overrides.
If you’re new to working with style variables, there may be a slight learning curve—but once you’re familiar, you’ll gain speed, flexibility, and cleaner code.
```ts
// [!code word:dark-mode]
```
If you're looking for building a dark mode toggle in either Next.js or Vite project, please check out the theme toggle example in our [Next.js integration](/integrations/nextjs#theme-toggle) or [Vite integration](/integrations/vite#theme-toggle) guides.