Theme Switch
InputMITSegmented dark / light / system theme switcher with smooth icon transitions.
bun add @otfdashkit/ui
Preview
Theme SwitchInput
Loading Storybook preview…
Code
@otfdashkit/uiimport { ThemeSwitch, Body, Caption } from '@otfdashkit/ui'
export function Example() {
return (
<div className="space-y-3">
<Caption>Segmented (default)</Caption>
<ThemeSwitch />
<Body size="sm" tone="muted">
Toggles the <code>dark</code> class on <code><html></code>.
Selection persists in localStorage under <code>otf-color-scheme</code>.
</Body>
</div>
)
}
Free with the SDK. This component ships in @otfdashkit/ui under the MIT license.
Props
Props declared in the ThemeSwitch source. Inherited HTML attributes are not listed.
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | ||
| defaultMode | 'light' | 'dark' | 'system' | Controlled initial mode. Falls back to localStorage + system. | |
| onChange | (mode: Mode) => void | ||
| variant | 'segmented' | 'button' | 'segmented' | Render as a three-way segmented control (default) or a single cycling button. |