Toggle

The Toggle component is used to switch between two states, such as on/off.

Usage

Default


const [checked, setChecked] = useState(false);

<Toggle
  checked={checked}
  onChange={setChecked}
  label="Enable setting"
  theme="primary"
/>

Props

Sortable data table
PropTypeDefaultDescription
checkedboolean-Whether the toggle is currently active or on.
onChange(checked: boolean) => void-Callback fired when the toggle state changes.
labelstring-Text label displayed next to the toggle.
theme"primary" | "secondary" | "tertiary" | "quaternary" | "clear"Configured DefaultDefines the visual theme of the toggle.
size"xs" | "small" | "medium" | "large" | "xl"Configured DefaultSpecifies the size of the toggle component.
rounding"none" | "small" | "medium" | "large"Configured DefaultControls the border radius of the toggle.
shadow"none" | "light" | "medium" | "strong" | "intense"Configured DefaultApplies a shadow effect to the toggle.
state"success" | "error" | "warning"-Applies a validation state style.
disabledbooleanfalseDisables the toggle, preventing user interaction.
classNamestring-Custom class name for the toggle root element.
data-testidstring"toggle"Test ID for the toggle element, useful for testing utilities.