Klarhimmel UI

Dark mode

Light, dark or the visitor's system setting, with no code per block.

Steps

  1. Pick a mode

    system follows the operating system, light and dark pin it.

    <Theme theme="brand" mode="system">…</Theme>
  2. Offer a toggle

    The navbar's theme toggle sends kh:theme-toggle. Theme handles it; a later change of the system setting takes over again.

    // navbar-simple props
    { themeToggle: true }
  3. Remember the choice

    Nothing is stored for you. If you want the choice to survive a reload, save it and pass it as mode.

    const saved = localStorage.getItem('mode') ?? 'system';
    <Theme mode={saved}>…</Theme>