Skip to content
Calm motion: animations on this site only fade, with no movement

ThemeToggle ​

Light/dark switch or 3-way group

The control for dark mode. Default is a single button ("Dark theme", aria-pressed when it is on) for a nav bar. mode="group" is light / system / dark as a toggle group, for a settings page. The switch can only ever set light or dark, so once pressed it leaves system behind. Offer the group where you want the OS to stay in charge. labels translates the names ({ light, system, dark }. The switch reads dark).

Its pressed state depends on the OS preference, which the server cannot know, so it renders unpressed until mounted and server and client markup agree. To avoid the one-frame default before a saved theme applies, add the head script from the guide.

Basic

Usage ​

ts
import { BlessThemeToggle } from "blessing-ui";

API ​

Props

NameTypeDefaultDescription
mode"group" | "switch""switch"three-way (light/system/dark) or a single light↔dark button
labelstring—the group's name; wins over `labels.theme`
labelsPartial<{ theme: string; light: string; system: string; dark: string; darkTheme: string; }>—accessible names: the group reads `theme` and all three; the switch reads `darkTheme` (or `dark`, if you set it) with pressed / not pressed

Released under the MIT License. Character names and artwork belong to their owners.