packages/insomnia-component-docs/docs/Components/switch.mdx
import { Switch } from 'insomnia/src/ui/components/base/switch';
A toggle switch component built on top of React Aria Components, providing an accessible binary on/off control with smooth animations and visual feedback.
| Prop | Type | Required | Description |
|---|---|---|---|
isSelected | boolean | No | Controlled selected state |
defaultSelected | boolean | No | Default selected state for uncontrolled mode |
onChange | (isSelected: boolean) => void | No | Callback fired when the switch state changes |
isDisabled | boolean | No | Whether the switch is disabled |
<Switch />
<Switch defaultSelected={true} />
<Switch isDisabled />
<Switch isDisabled />
The component uses the following CSS variables for theming:
--color-bg: Switch background color (track and selected knob)--color-surprise: Switch primary color (unselected knob, selected track)--hl: Border color for track and disabled stateYou can customize these variables in your CSS to theme the switch appearance.
While visually different, Switch and Checkbox serve similar purposes. Use Switch when: