Toggle
A two-state toggle button supporting both controlled and uncontrolled usage via the useControllable hook.
Uncontrolled
Controlled
Colors
With Icons
Props
| Prop | Type | Default | Description |
|---|---|---|---|
pressed | boolean | — | Whether the toggle is pressed (controlled). |
defaultPressed | boolean | false | The initial pressed state (uncontrolled). |
onPressedChange | (pressed: boolean) => void | — | Called when the pressed state changes. |
color | "blue" | "red" | "green" | "yellow" | "purple" | "neutral" | string | "blue" | Accent color. |
disabled | boolean | false | Disables the toggle. |
--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" }} |
--mantle-hover | CSS variable | gradient | Override the hover background via style. Set to "none" to disable. e.g. style={{ "--mantle-hover": "none" }} |
pressedbooleanWhether the toggle is pressed (controlled).
defaultPressedfalsebooleanThe initial pressed state (uncontrolled).
onPressedChange(pressed: boolean) => voidCalled when the pressed state changes.
color"blue""blue" | "red" | "green" | "yellow" | "purple" | "neutral" | stringAccent color.
disabledfalsebooleanDisables the toggle.
--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" }}
--mantle-hovergradientCSS variableOverride the hover background via style. Set to "none" to disable. e.g. style={{ "--mantle-hover": "none" }}