Switch

A control that allows the user to toggle between checked and not checked.

Features

  • Full keyboard navigation.
  • Can be controlled or uncontrolled.

Install the component from your command line.

Import the components and piece the parts together.

Create your styled switch component from the primitive parts.

Contains all the parts of a switch.

PropTypeDefaultRequired
asenumbutton
defaultCheckedboolean
checkedboolean
onCheckedChangefunction
disabledboolean
requiredboolean
readOnlyboolean
namestring
valuestringon

The thumb that is used to visually indicate whether the switch is on or off.

PropTypeDefaultRequired
asenumspan

Adheres to the switch role requirements.

KeyDescription
SpaceToggles the component's state.
EnterToggles the component's state.