ThemeToggle
molecules
Moon-icon IconButton that toggles data-theme between 'light' and 'dark' on documentElement. Persists to localStorage. aria-pressed reflects state.
ARIA Role: button
Demo
Demo for ThemeToggle (molecules)
Moon-icon IconButton that toggles data-theme between 'light' and 'dark' on documentElement. Persists to localStorage. aria-pressed reflects state.
Props
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
pressed | boolean | Yes | — | |
onToggle | () => void | Yes | — |
TypeScript Interface
interface ThemeToggleProps {
pressed?: boolean;
onToggle: () => void;
ariaLabel?: string;
}Assertions (NASA Rule 5)
- [type]onToggle required(NASA Rule 5)
- [aria]aria-pressed must reflect theme state; aria-label must NOT change with state (would confuse SR)(WCAG 4.1.2)
Usage
Import
import { Themetoggle } from '@epasslive/design-system'Basic
<Themetoggle />With Variants
<Themetoggle variant="primary" size="md" />