A control that indicates whether a setting is on or off.
import { Switch } from '@backstage/ui';
<Switch />| Prop | Type | Default | Responsive |
|---|---|---|---|
| autoFocus | boolean | - | No |
| defaultSelected | boolean | - | No |
| className | string | - | No |
| isDisabled | boolean | - | No |
| isReadOnly | boolean | - | No |
| isSelected | boolean | - | No |
| label | string | - | No |
| name | string | - | No |
| onChange | (isSelected: boolean) => void | - | No |
| onFocus | (e: FocusEvent<Target>) => void | - | No |
| onBlur | (e: FocusEvent<Target>) => void | - | No |
| onFocusChange | (isFocused: boolean) => void | - | No |
| onKeyDown | (e: KeyboardEvent) => void | - | No |
| onKeyUp | (e: KeyboardEvent) => void | - | No |
| onHoverStart | (e: HoverEvent) => void | - | No |
| onHoverEnd | (e: HoverEvent) => void | - | No |
| onHoverChange | (isHovered: boolean) => void | - | No |
| style | CSSProperties | - | No |
| value | string | - | No |
A switch can be disabled using the isDisabled prop.
<Switch isDisabled />Our theming system is based on a mix between CSS classes, CSS variables and data attributes. If you want to customise this component, you can use one of these class names below.
bui-Switchbui-SwitchIndicator0.5.0 - New Switch component #30251