Sajari UI

Switch

The Switch component is used as an alternative for the Checkbox component, switch between enabled or disabled states.

Switch must always be accompanied by a label, and follows the same keyboard workflow as a checkbox.

Import

Usage

Editable Example

Disabled

Editable Example

Invalid

Editable Example

Props

NameTypeDefaultDescription
idstringThe id of the switch for associated with a label.
namestringThe input name of the switch when used in a form.
valuestring, booleanThe value of the switch.
childrenReact.ReactNodeThe children of the switch.
aria-labelstringThe aria-label of the switch for accessibility.
aria-labelledbystringThe aria-labelledby of the switch for accessibility.
checkedbooleanIf true, set the switch to the checked state.
defaultCheckedbooleanIf true, the checkbox will be initially checked.
disabledbooleanIf true, set the disabled to the invalid state.
invalidbooleanIf true, set the switch to the invalid state.