Switch
A toggle switch for boolean settings, supporting controlled and uncontrolled modes with multiple sizes and colors.
Basic
With Labels
Sizes
Colors
With Thumb Icon
Display an icon inside the switch thumb that reflects the toggle state.
With Description
Add descriptive text below the label for additional context.
Controlled
Props
| Prop | Type | Default | Description |
|---|---|---|---|
checked | boolean | — | Whether the switch is on (controlled). |
defaultChecked | boolean | false | The initial on/off state (uncontrolled). |
onCheckedChange | (checked: boolean) => void | — | Called when the switch state changes. |
color | "blue" | "red" | "green" | "yellow" | "purple" | "neutral" | string | "blue" | Accent color when the switch is on. |
size | "sm" | "md" | "lg" | "md" | Size preset. |
label | string | — | Label text displayed next to the switch. |
disabled | boolean | false | Disables the switch. |
description | ReactNode | — | Description text displayed below the label. |
thumbIcon | ReactNode | — | Icon displayed inside the switch thumb. |
--mantle-bg | CSS variable | theme default | Override the background color via style. e.g. style={{ "--mantle-bg": "#1a1a2e" }} |
--mantle-border | CSS variable | theme default | Override the border color via style. Set to "transparent" to remove. e.g. style={{ "--mantle-border": "#e94560" }} |
--mantle-text | CSS variable | theme default | Override the text color via style. e.g. style={{ "--mantle-text": "#ffffff" }} |
--mantle-ring | CSS variable | accent | Override the focus ring color via style. e.g. style={{ "--mantle-ring": "#e94560" }} |
checkedbooleanWhether the switch is on (controlled).
defaultCheckedfalsebooleanThe initial on/off state (uncontrolled).
onCheckedChange(checked: boolean) => voidCalled when the switch state changes.
color"blue""blue" | "red" | "green" | "yellow" | "purple" | "neutral" | stringAccent color when the switch is on.
size"md""sm" | "md" | "lg"Size preset.
labelstringLabel text displayed next to the switch.
disabledfalsebooleanDisables the switch.
descriptionReactNodeDescription text displayed below the label.
thumbIconReactNodeIcon displayed inside the switch thumb.
--mantle-bgtheme defaultCSS variableOverride the background color via style. e.g. style={{ "--mantle-bg": "#1a1a2e" }}
--mantle-bordertheme defaultCSS variableOverride the border color via style. Set to "transparent" to remove. e.g. style={{ "--mantle-border": "#e94560" }}
--mantle-texttheme defaultCSS variableOverride the text color via style. e.g. style={{ "--mantle-text": "#ffffff" }}
--mantle-ringaccentCSS variableOverride the focus ring color via style. e.g. style={{ "--mantle-ring": "#e94560" }}