featherbit UI
    Preparing search index...

    Function ThemeToggle

    • Icon button that toggles between dark and light mode.

      Initial state comes from localStorage 'theme' if set, otherwise from the OS preference (dark-first: dark unless the OS explicitly prefers light). Each change writes 'theme' back to localStorage and updates data-theme on the root element: the attribute is removed for dark (the stylesheet's default) and set to "light" for light mode.

      Returns Element

      The same bootstrap logic runs in main.tsx before React mounts, so the page paints in the persisted theme without a flash; keep the two in sync.