stnd.build

ColorModeToggle (.svelte)

The switch for the colour mode: auto (the system decides), light or dark. As a button it is one row that cycles through the three; as a segmented group it shows them side by side. It sets data-color-mode on the page and remembers the choice (see color-mode.js), and it follows the page if something else changes the mode (a launcher command, another switch). In a folded sidebar, hide .color-mode-label and only the icon shows.

Type Name Description
“button” | “segmented” variant? One button that cycles, or three side by side. Defaults to “button”.
{ name?: string, auto?: string, light?: string, dark?: string } [labels] – The words, for another language.
boolean showLabel? Write the current mode next to the icon (button variant). Defaults to true.
“local” | “none” storage? “none” when the host keeps the choice itself, on an account for one.
(mode: “auto” | “light” | “dark”) => void onchange? Called after the person changes the mode.
string class? Extra classes.
<ColorModeToggle />
<ColorModeToggle variant="segmented" labels={{ name: "Thème", auto: "Auto", light: "Clair", dark: "Sombre" }} />