An on or off setting in one row
The whole bar is the switch, with the name on the left and the ToggleSwitch track at the end, compact in a compact bar. A native checkbox with role="switch" covers the bar, so a click anywhere toggles it, Space toggles it from the keyboard, and both checked and defaultChecked work. On looks the same as a form switch: the action colour, with a check in the thumb.
Sizes
The size prop matches Button’s: default is 40px tall and compact is 32px.
Off and on
Disabled
When to use it
Use the inspector toggle switch for a setting that applies at once in a dense panel, usually inside an inspector section. For a standalone switch with its label beside it, in a form or a settings page with room to breathe, use Toggle switch instead.
Props
Read from the same JSDoc that ships in the package's types. A required prop is marked with an asterisk.
| Prop | Type | Default | Description |
|---|---|---|---|
label* | string | The setting's name, drawn inside the bar on the left. Also the switch's accessible name. | |
size | "default" | "compact" | 'default' | Component size, matching Button: `default` is 40px tall, `compact` 32px (not the native character-width `size` attribute). |
onCheckedChange | ((checked: boolean) => void) | Convenience callback receiving the checked state directly.
Fires alongside `onChange`, which keeps the standard React event signature. | |
className | string | '' | Additional CSS classes, applied to the bar rather than the <input>. |
Tested keys
An automated test presses every row below, in a left-to-right and a right-to-left layout.
Inspector toggle switch follows the WAI-ARIA switch pattern.
| Key | What it does |
|---|---|
Space | Turns the switch on, or off when it is on. |
// From the npm package
import { InspectorToggleSwitch } from 'rift-ds/components/InspectorToggleSwitch/InspectorToggleSwitch';
// Or as source you own, via the shadcn CLI
npx shadcn@latest add https://rift-ds.com/r/inspector-toggle-switch.json2.4 kB gzipped, with everything it imports. Peer dependencies are not counted.
For agents: the props, their allowed values and defaults, and the tested keys, as markdown or as a JSON schema.