Selection controls
Selection controls patterns built with StyloftCSS and native HTML.
Checkbox
Native checked and disabled checkbox states.
View HTML / PlaygroundHTML source
<label class="sl-choice"><input type="checkbox" checked /> Receive sample updates</label
><label class="sl-choice"><input type="checkbox" disabled /> Unavailable option</label>HTML source · enable JavaScript for the playground2 lines · UTF-8
ReadyCtrl/⌘ + Enter to run · Scripts blocked
CheckboxGroup
Independent checkboxes grouped with a legend.
View HTML / PlaygroundHTML source
<fieldset class="sl-fieldset sl-stack">
<legend>Choose modules</legend>
<label class="sl-choice"
><input type="checkbox" name="ref-module" value="motion" checked /> Motion</label
><label class="sl-choice"
><input type="checkbox" name="ref-module" value="tables" /> Tables</label
><label class="sl-choice"
><input type="checkbox" name="ref-module" value="tabs" /> Tabs</label
>
</fieldset>HTML source · enable JavaScript for the playground10 lines · UTF-8
ReadyCtrl/⌘ + Enter to run · Scripts blocked
RadioGroup
Native mutually exclusive selection and keyboard navigation.
View HTML / PlaygroundHTML source
<fieldset class="sl-fieldset sl-stack">
<legend>Choose a plan</legend>
<label class="sl-choice"
><input type="radio" name="ref-plan" value="starter" checked /> Starter</label
><label class="sl-choice"
><input type="radio" name="ref-plan" value="studio" /> Studio</label
>
</fieldset>HTML source · enable JavaScript for the playground8 lines · UTF-8
ReadyCtrl/⌘ + Enter to run · Scripts blocked
Switch
A native checkbox exposed as a switch. The track and thumb transition smoothly.
View HTML / PlaygroundHTML source
<div class="sl-stack">
<label class="sl-switch"
><input type="checkbox" role="switch" checked /><span
class="sl-switch__track"
aria-hidden="true"
></span
><span>Enable sample preference</span></label
><label class="sl-switch"
><input type="checkbox" role="switch" disabled /><span
class="sl-switch__track"
aria-hidden="true"
></span
><span>Unavailable preference</span></label
>
</div>HTML source · enable JavaScript for the playground15 lines · UTF-8
ReadyCtrl/⌘ + Enter to run · Scripts blocked
Classes beginning with sl- come from StyloftCSS. Examples with demo- classes also use our optional demo extension CSS ↓. Load it after the core to reproduce those details.