Version 0.7.0 - Alpha
Switch
component

Switch

A control that indicates whether a setting is on or off.

Usage

import { Switch } from '@backstage/ui';

<Switch />

API reference

PropTypeDefaultResponsive
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

Examples

Disabled

A switch can be disabled using the isDisabled prop.

<Switch isDisabled />

Theming

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.

Changelog