Switch
Turn a setting on or off immediately.
Basic usage
Use the switch to toggle on/off state and provide an associated label.
Examples
Disabled and loading
disabled prevents interaction. Set loading while saving to prevent repeated changes; the application performs the async operation.
Sizes
Use size to set the switch size.
Controlled state
Pass checked and read the boolean from event.target.checked in onChange.
With name, an enabled, checked switch submits its value. Unchecked, disabled or loading switches are not submitted. Uncontrolled switches return to defaultChecked on form reset; reset application state as well for a controlled switch.
API
Switch API
Configure checked state, form submission and interaction state.
Supports native checkbox attributes such as name, value, required and form. Provide text or aria-label as its accessible name. className and style apply to the label container.