Skip to main content

Switch

Give users a clear way to toggle options on or off.

string

A label used for users using assistive technologies like screen readers. When set, any children or label supplied will not be announced. This can also be used to display a control without a visual label, while still providing context to users using screen readers.

boolean

Whether the control is active.

boolean

Whether the control is active by default.

string

Additional text to provide context or guidance for the field. This text is displayed along with the field and its label to offer more information or instructions to the user.

This will also be exposed to screen reader users.

boolean

Disables the field, disallowing any interaction.

string

Indicate an error to the user. The field will be given a specific stylistic treatment to communicate problems that have to be resolved immediately.

string

A unique identifier for the element.

string

Visual content to use as the control label.

Anchor to labelAccessibilityVisibility
labelAccessibilityVisibility
"visible" | "exclusive"

Changes the visibility of the component's label.

  • visible: the label is visible to all users.
  • exclusive: the label is visually hidden but remains in the accessibility tree.
string

An identifier for the field that is unique within the nearest containing form.

boolean

Whether the field needs a value. This requirement adds semantic value to the field, but it will not cause an error to appear automatically. If you want to present an error when this field is empty, you can do so with the error property.

string

The value used in form data when the checkbox is checked.

Was this section helpful?

Learn more about registering events.

<'input'>
<'input'>
Was this section helpful?

Code

<s-switch
label="Enable feature"
details="Ensure all criteria are met before enabling"
></s-switch>

Preview