Skip to content
KinetixUI

Dark Mode

The dark theme is a .dark class on <html>. @kinetixui/tokens/css/dark redefines the semantic contract under that selector — primitives are unchanged.

The dark theme is its own palette, not a flip of the light one: each role in tokens/semantic/color.dark.json is mapped to a primitive step chosen for the dark surface (--primary is indigo.300 in dark and indigo.600 in light), and pnpm check:contrast holds both modes to the same WCAG targets. A custom theme needs a dark value for every role it overrides — see Theming.

Next.js#

// app/layout.tsx
import { ThemeProvider } from "next-themes";
 
export default function RootLayout({ children }) {
  return (
    <html lang="en" suppressHydrationWarning>
      <body>
        <ThemeProvider attribute="class" defaultTheme="system" enableSystem>
          {children}
        </ThemeProvider>
      </body>
    </html>
  );
}

This very site uses exactly that. Toggle it from the header — the whole page, including these code blocks, re-themes off the same contract.

Vanilla#

document.documentElement.classList.toggle("dark");

Any framework works; the contract is just CSS.