Skip to content

Switch

A controlled switch for boolean settings.

Receive product updates and account alerts.
<SwitchStory {...args} />
Loading
Loading
Loading
<VStack gap={4}>
<Switch isSelected={false} label="Off" onChange={() => {}} />
<Switch isSelected label="On" onChange={() => {}} />
<Switch
isDisabled
isSelected={false}
label="Disabled"
onChange={() => {}}
/>
<Switch
isDisabled
isLoading
isSelected
label="Disabled loading"
onChange={() => {}}
/>
<Switch
isLoading
isSelected={false}
label="Loading off"
onChange={() => {}}
/>
<Switch isLoading isSelected label="Loading" onChange={() => {}} />
</VStack>
Receive product updates and account alerts.
<SwitchStory {...args} />
Receive product updates and account alerts.
<SwitchStory {...args} />
Receive product updates and account alerts.
<SwitchStory {...args} />
<SwitchStory {...args} />
Receive product updates and account alerts.
<SwitchStory {...args} />
Receive product updates and account alerts.
<SwitchStory {...args} />
<VStack gap={4}>
<Switch
isRequired
isSelected
label="Required setting"
onChange={() => {}}
/>
<Switch
isOptional
isSelected={false}
label="Optional setting"
onChange={() => {}}
/>
</VStack>
This longer description explains when the setting applies and wraps onto multiple lines in constrained layouts.
<VStack gap={4}>
<Switch isSelected label="Compact setting" onChange={() => {}} />
<Switch
description="This longer description explains when the setting applies and wraps onto multiple lines in constrained layouts."
isSelected
label="Detailed setting"
onChange={() => {}}
style={{maxWidth: 360}}
/>
</VStack>
Receive product updates and account alerts.
Notification delivery may be delayed.
<SwitchStory {...args} />
Receive product updates and account alerts.
This setting is active and healthy.
<SwitchStory {...args} />

A controlled switch for boolean settings.

When isOptional: false, isRequired: false

PropTypeDefaultDescription
classNamestringAdditional CSS class names applied to the field root.
data-testidstringTest ID applied to the checkbox input.
descriptionReactNodeSupporting text displayed below the label.
isDisabledbooleanfalseWhether the switch is disabled.
isLabelHiddenbooleanfalseWhether to visually hide the label.
isLoadingbooleanfalseWhether the switch is loading.
isSelected*booleanWhether the switch is on.
label*stringSwitch label.
labelIconIconComponentContent rendered before the label.
labelPosition"end" | "start"'end'Which side of the switch the label appears on.
labelSpacing"default" | "spread"'default'Spacing behavior between label and switch.
labelTooltipReactNodeTooltip content shown next to the label.
onBlur(event: FocusEvent<HTMLInputElement>) => voidCalled when the switch loses focus.
onChange*(checked: boolean, event: ChangeEvent<HTMLInputElement>) => voidCalled when the checked state changes.
onFocus(event: FocusEvent<HTMLInputElement>) => voidCalled when the switch receives focus.
refRef<HTMLInputElement>Ref forwarded to the checkbox input.
statusInputStatusValidation status displayed below the switch.
styleCSSPropertiesInline styles applied to the field root.
isOptionalfalse
isRequiredfalse

When isOptional: true, isRequired: false

PropTypeDefaultDescription
classNamestringAdditional CSS class names applied to the field root.
data-testidstringTest ID applied to the checkbox input.
descriptionReactNodeSupporting text displayed below the label.
isDisabledbooleanfalseWhether the switch is disabled.
isLabelHiddenbooleanfalseWhether to visually hide the label.
isLoadingbooleanfalseWhether the switch is loading.
isSelected*booleanWhether the switch is on.
label*stringSwitch label.
labelIconIconComponentContent rendered before the label.
labelPosition"end" | "start"'end'Which side of the switch the label appears on.
labelSpacing"default" | "spread"'default'Spacing behavior between label and switch.
labelTooltipReactNodeTooltip content shown next to the label.
onBlur(event: FocusEvent<HTMLInputElement>) => voidCalled when the switch loses focus.
onChange*(checked: boolean, event: ChangeEvent<HTMLInputElement>) => voidCalled when the checked state changes.
onFocus(event: FocusEvent<HTMLInputElement>) => voidCalled when the switch receives focus.
refRef<HTMLInputElement>Ref forwarded to the checkbox input.
statusInputStatusValidation status displayed below the switch.
styleCSSPropertiesInline styles applied to the field root.
isOptional*true
isRequiredfalse

When isOptional: false, isRequired: true

PropTypeDefaultDescription
classNamestringAdditional CSS class names applied to the field root.
data-testidstringTest ID applied to the checkbox input.
descriptionReactNodeSupporting text displayed below the label.
isDisabledbooleanfalseWhether the switch is disabled.
isLabelHiddenbooleanfalseWhether to visually hide the label.
isLoadingbooleanfalseWhether the switch is loading.
isSelected*booleanWhether the switch is on.
label*stringSwitch label.
labelIconIconComponentContent rendered before the label.
labelPosition"end" | "start"'end'Which side of the switch the label appears on.
labelSpacing"default" | "spread"'default'Spacing behavior between label and switch.
labelTooltipReactNodeTooltip content shown next to the label.
onBlur(event: FocusEvent<HTMLInputElement>) => voidCalled when the switch loses focus.
onChange*(checked: boolean, event: ChangeEvent<HTMLInputElement>) => voidCalled when the checked state changes.
onFocus(event: FocusEvent<HTMLInputElement>) => voidCalled when the switch receives focus.
refRef<HTMLInputElement>Ref forwarded to the checkbox input.
statusInputStatusValidation status displayed below the switch.
styleCSSPropertiesInline styles applied to the field root.
isOptionalfalse
isRequired*true