Skip to content
Frauthy Brand
Frauthy index

Go anywhere.

    No exact contract found. Try a component family, product name, prop, or keyboard key.

    ↑↓ move↵ openesc close

    ThemeToggle

    interactive

    Light/dark theme toggle. Writes data-theme on<html>, persists to localStorage. Pair with themeInitScript in the head to prevent flash of wrong theme.

    Preview

    Click to toggle. Persists to localStorage.

    Usage

    import { ThemeToggle, themeInitScript } from 'PRIVATE_BETA_PACKAGE_COORDINATE_REDACTED';
    
    // In your <head> (prevents FOUC)
    <script>{themeInitScript}</script>
    
    // In your header/nav
    <ThemeToggle />

    Props

    PropTypeDefaultDescription
    classstring--Additional CSS classes

    Exports

    ExportTypeDescription
    ThemeToggleComponentThe toggle button component
    themeInitScriptstringInline script to set data-theme before first paint (no FOUC)

    Accessibility

    How it works

    No FOUC: The themeInitScript runs synchronously in the head, reading localStorage and setting data-theme before the first paint. The component then reads the DOM attribute on mount to sync its internal state.

    Do / Don't

    Do

    Always pair the component with themeInitScript in the head. Place it in a consistent, discoverable location (header).

    Don't

    Don't render multiple ThemeToggle instances -- they share localStorage and may conflict.