Theme

The theme system persists a base theme (light / dark / system) plus an optional liquid flag, resolves the active theme, and reflects it on html[data-theme] — the attribute the kit's tokens key off.

Live toggles drive html[data-theme] for the whole page, so this page documents them with code rather than an embedded demo (which would fight the docs site's own theme switch).

Setup

Wrap your app once in ThemeProvider, and import the kit's stylesheet at the root so the tokens are present:

tsx
import { ThemeProvider } from '@dreamlake/uikit'
import '@dreamlake/uikit/styles.css'

export function App() {
  return (
    <ThemeProvider defaultBaseTheme="system">
      {/* …app… */}
    </ThemeProvider>
  )
}

Toggles

ThemeColorToggle cycles light → dark → system; LiquidToggle flips the liquid flag. Both must be inside a ThemeProvider.

tsx
import { ThemeColorToggle, LiquidToggle } from '@dreamlake/uikit'

<header>
  <ThemeColorToggle />
  <LiquidToggle />
</header>

useTheme

Read or drive the theme from anywhere under the provider:

tsx
import { useTheme } from '@dreamlake/uikit'

function Example() {
  const { baseTheme, setBaseTheme, isLiquid, toggleLiquid, computedTheme } = useTheme()
  return <button onClick={() => setBaseTheme('dark')}>Now: {computedTheme}</button>
}
MemberTypeDescription
baseTheme'light' | 'dark' | 'system'The stored base theme.
setBaseTheme(t: BaseTheme) => voidSet + persist the base theme.
isLiquidbooleanLiquid flag.
toggleLiquid() => voidFlip the liquid flag.
computedTheme'light' | 'dark' | 'liquid-light' | 'liquid-dark'Resolved active theme.
resolvedTheme'light' | 'dark' | 'liquid-light' | 'liquid-dark'Alias of computedTheme.
systemTheme'light' | 'dark' | undefinedOS preference (when system).
storageKeystringThe localStorage key prefix in use.

ThemeProvider props

PropTypeDefaultDescription
defaultBaseThemeBaseTheme'system' (or 'light' if system disabled)Initial base theme.
defaultIsLiquidbooleanfalseInitial liquid flag.
enableSystembooleantrueTrack the OS color-scheme preference.
storageKeystring'dl-theme'localStorage key prefix.