Switch

Switches let users toggle a single setting on or off immediately, without needing to submit a form to see the state change.

Example

Add role="switch" to a checkbox to indicate it represents an on/off setting that takes effect immediately, rather than a form field awaiting submission.

Disabled

Add the disabled attribute to prevent a switch from being toggled or focused, and exclude its value from form submission.

Hint

Associate a switch with helper text using aria-describedby, so users understand what the setting controls before toggling it.

We will send you a newsletter every week

Validation

You can indicate the validation state of the switch using the attribute aria-invilid with the values true and false.

Looks good! Please provide a valid value!