Getting started
Dark mode
Connect DavinciUI's semantic tokens to next-themes and keep every component legible in light and dark.
DavinciUI uses the same semantic CSS variables as shadcn. Dark mode is a class on the <html> element; components do not ship separate dark styles.
How the token switch works
The :root block defines light values and the .dark block overrides them. Every component reads tokens such as --background, --foreground, and --border, so changing the class updates the whole page.
Do not hard-code colors in component overrides. Change the token instead so both modes stay consistent.
Add a theme provider
"use client"
import { ThemeProvider } from "next-themes"
export function Providers({ children }: { children: React.ReactNode }) {
return (
<ThemeProvider attribute="class" defaultTheme="system" enableSystem>
{children}
</ThemeProvider>
)
}import { Providers } from "./providers"
export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<html lang="en" suppressHydrationWarning>
<body>
<Providers>{children}</Providers>
</body>
</html>
)
}Add a toggle
"use client"
import { Moon, Sun } from "lucide-react"
import { useTheme } from "next-themes"
export function ThemeToggle() {
const { resolvedTheme, setTheme } = useTheme()
return (
<button
type="button"
aria-label="Toggle theme"
onClick={() => setTheme(resolvedTheme === "dark" ? "light" : "dark")}
>
{resolvedTheme === "dark" ? <Sun /> : <Moon />}
</button>
)
}Tune the palette
Update the :root and .dark blocks in app/globals.css.
Check body text, muted text, and borders against the new background before shipping.
Toggle the theme on every component page. Pay attention to code blocks and disabled states.
Pass suppressHydrationWarning to <html> so next-themes can set the class before React hydrates.

