This page as markdown: /theme-switcher.md · Index for agents: /llms.txt · Everything in one file: /llms-full.txt

ThemeSwitcher

Status: stable

A segmented light / dark / system switch. Presentational: it renders the selected color preference and reports changes via onValueChange; pair it with useSableTheme() when the app uses SableThemeProvider. A radiogroup of three icon buttons (sun / moon / desktop).

Keywords: theme switcher, color mode, dark mode, appearance

Usage

Use ThemeSwitcher for light, dark, and system color mode preference.

Best practices

Props

Name Type Default Description
value "light" | "dark" | "system" — The currently selected color preference.
onValueChange (value: ThemeMode) => void — Called with the next color preference when an option is chosen.
label string "Theme" Accessible label for the radiogroup.
motion "full" | "subtle" | "off" "full" How much motion this component uses: full (default) inherits the app's policy, subtle keeps feedback and drops the glide, off stills it. It can only turn motion down — it never overrides a reader's reduce-motion setting.
className string — Merged onto the outer radiogroup container.

Tokens used

border, card, muted-foreground, foreground, accent, accent-foreground, ring

Motion

Accessibility

Related

Examples

Controlled

import { ThemeSwitcher, type ThemeMode } from "@sableui/react"

const [theme, setTheme] = useState<ThemeMode>("system")
<ThemeSwitcher value={theme} onValueChange={setTheme} />

With SableThemeProvider

import { ThemeSwitcher, useSableTheme } from "@sableui/react"

const { preference, setPreference } = useSableTheme()
<ThemeSwitcher value={preference} onValueChange={setPreference} />

Light selected

import { ThemeSwitcher } from "@sableui/react"

<ThemeSwitcher value="light" onValueChange={setTheme} />

Subtle motion

import { ThemeSwitcher } from "@sableui/react"

<ThemeSwitcher value={theme} onValueChange={setTheme} motion="subtle" />