Skip to content
SENVENLI UI

Theme switcher

Lets people choose system, light or dark theme, stored per device and applied before first paint.
In a site header
import { ThemeSwitcher } from "@senvenli/react/action";

Examples

As a list

The same choice as three rows with a check, for a phone menu.

Controlled

With `value`, the parent owns the theme: the toggle stores and applies nothing.

Guidelines

When to use it

  • An app or site offers light and dark themes.

Use something else when

  • Only two themes exist and the system option is not offered. Switch
  • The theme choice sits among other account settings. Menu

Accessibility

Keyboard

KeysWhat happens
Arrow keysMoves between and selects the options.

Built in

  • One tab stop; a radio group named "Theme".
  • System says which theme is in effect now.

API reference

ThemeSwitcher

value
ThemeChoice

Controlled choice; leave out to let the toggle manage, store and apply it.

onChange
(choice: ThemeChoice) => void
labels
Partial<ThemeLabels>

Localized names; the locale's built-in strings by default.

storageKey
string
variant
"list" | "menu" | "segmented"Default "segmented"

segmented: three icon buttons. menu: one icon button (the theme in effect) that opens System / Light / Dark, the compact form for a busy header. list: a three-option list with a check, for the phone menu.