Switch
A control that indicates whether a setting is on or off.
Usage guidelines
- Form controls must have an accessible name: give it one with a
<label>element or the Field parts. See Labeling a switch.
Anatomy
Import the primitives and assemble the parts:
@using Blazix.Primitives
<SwitchRoot>
<SwitchThumb />
</SwitchRoot>Examples
Labeling a switch
An enclosing <label> is the simplest labeling pattern:
<label>
<SwitchRoot />
Notifications
</label>SwitchRoot renders a <span> with a hidden native <input> beside it.
To label it with a sibling <label>, point the label's for at the hidden input's id,
set with InputId:
<div>
<label for="notifications-switch">Notifications</label>
<SwitchRoot InputId="notifications-switch">
<SwitchThumb />
</SwitchRoot>
</div>API Reference
SwitchRoot
Renders a <span> element.
Other attributes are passed to the element it renders.
SwitchThumb
Renders a <span> element.
Other attributes are passed to the element it renders.