Switch
Give users a clear way to toggle options on or off.
Anchor to propertiesProperties
- Anchor to accessibilityLabelaccessibilityLabelstring
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.- Anchor to checkedcheckedboolean
Whether the control is active.
- Anchor to defaultCheckeddefaultCheckedboolean
Whether the control is active by default.
- Anchor to detailsdetailsstring
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.
- Anchor to disableddisabledboolean
Disables the field, disallowing any interaction.
- Anchor to errorerrorstring
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.
- Anchor to labellabelstring
Visual content to use as the control label.
- Anchor to labelAccessibilityVisibilitylabelAccessibilityVisibility"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.
- Anchor to namenamestring
An identifier for the field that is unique within the nearest containing form.
- Anchor to requiredrequiredboolean
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.- Anchor to valuevaluestring
The value used in form data when the checkbox is checked.
Anchor to eventsEvents
Learn more about registering events.
- Anchor to changechangeCallbackEventListener<'input'>
- Anchor to inputinputCallbackEventListener<'input'>
CallbackEventListener
(EventListener & {
(event: CallbackEvent<T>): void;
}) | null
CallbackEvent
Event & {
currentTarget: HTMLElementTagNameMap[T];
}
Code
Examples
Code
Default
<s-switch label="Enable feature" details="Ensure all criteria are met before enabling" ></s-switch>