Switch

A switch is a visual toggle between two mutually exclusive states — on and off.

Examples

Uncontrolled state

To use Switch in uncontrolled mode with an initial value, use the isDefaultChecked prop.

Controlled state

Optionally, to use Switch in controlled mode, use the isChecked and onCheckedChanged props with your local state.

Helper text

The helperText prop can be used to provide additional information about the input field below it.

Receive all account notifications via email.

API Reference

PropDefaultDescription
isChecked?-boolean

If true, the switch will be checked

onCheckedChange?-((isChecked: boolean) => void)
isDefaultChecked?-boolean

The checked state of the checkbox when it is initially rendered. Use when you do not need to control its checked state.

isDisabled?-boolean

If true, the switch will be disabled and cannot be interacted with

isRequired?-boolean

If true, indicates that the switch is required

label-string

The label for the switch