Skip to components
DEVELOPER REFERENCE · v4.0.0

Switch API

Props, callbacks and methods. Select an underlined type to explore its fields, allowed values and callback arguments.

Switch8 props1 callbacks0 methods

Props8

Switch props
NameTypeDescription
checkedRequiredbooleanChecked state displayed by the checkbox or switch.
labelRequiredanyLabel content or accessible name for the component, as rendered by this control.
ariaLabelOptionalstring | undefinedAccessible name announced by assistive technology.
classNameOptionalstring | undefinedAdditional CSS classes applied to the component root.
disabledOptionalboolean | undefinedDisables user interaction with the control.
labelPositionOptional"before" | "after" | undefinedPlaces the switch label before or after the control.
titleOptionalstring | undefinedHeading or title text used by this component.
testIdOptionalstring | undefinedStable data attribute for locating the control in automated tests.

Events and callbacks1

Switch events and callbacks
NameTypeDescription
onChangeRequired
(checked: boolean) => voidInspect type
Receives the new value when the user changes the control. Update the corresponding value prop for controlled use.

Methods0

No component-specific imperative methods. Use props and callbacks to control this component.