Switch
An on/off toggle built on a native checkbox with role="switch".
States
Section titled “States”<div class="stack">
<label class="opt"><input type="checkbox" role="switch" class="re-switch" /> Off</label>
<label class="opt"
><input type="checkbox" role="switch" class="re-switch" checked /> On</label
>
<label class="opt">
<input type="checkbox" role="switch" class="re-switch" disabled /> Disabled
</label>
<label class="opt">
<input type="checkbox" role="switch" class="re-switch" checked disabled /> Disabled on
</label>
</div> Accessibility
Section titled “Accessibility”- Keyboard — fully native. Tab moves focus to the switch; Space toggles it on and off. There’s no custom keyboard layer.
- Focus — a visible ring shows only on
:focus-visible(keyboard focus), drawn as abox-shadow(--re-shadow-focus) that replaces the default outline. - Semantics — it stays a real
<input type="checkbox">withrole="switch", so assistive tech announces it as a switch and reports its on/off state, while click, keyboard, and form serialization stay native. Wrapping the input in a<label>(with the option text alongside it) gives an implicit label, so the text is announced as the switch’s name and the whole label is a click/tap target. - Notes — the track fill, thumb, and travel are pure CSS (no SVG or extra markup), so the on/off state is conveyed visually by the thumb position rather than by an added glyph. Under
@media (forced-colors: active)(Windows High Contrast) the checked track is tinted with systemHighlightso “on” stays distinct from “off”.:disableddims the control and shows anot-allowedcursor; the nativedisabledattribute also removes it from the tab order and announces it as unavailable. See the accessibility guide.