Overview
Boolean and single-choice controls share the native <input> + <label> + visual __control pattern (icon font for checkbox ticks). Checkbox adds an indeterminate state for “select some” trees and tables.
| HTML | PimentCSS | Doc |
|---|---|---|
input[type="text|email|tel|…"] | .field + .field__input | Input fields |
textarea | .textarea + .textarea-field | Input fields |
select | .field + select.field__input | Input fields |
input[type="checkbox"] | .checkbox | This page |
input[type="radio"] | .radio + fieldset | This page |
role="switch" | .switch | This page |
| Custom listbox | .dropdown + .menu | Menu & dropdown |
| Control | Source | Notes |
|---|---|---|
| Checkbox | scss/components/_checkbox.scss | Checked, indeterminate, error |
| Radio | scss/components/_radio.scss | One name per group |
| Switch | scss/components/_switch.scss | role="switch", aria-checked |
Prerequisites
- PimentCSS installed, Installation.
- Input fields, labels and hints from Input fields.
- Focus,
:focus-visiblerings on__control(3px).
Checkboxes
Wrap with .checkbox: hidden input, .checkbox__control, then label text. Icons for check and minus live inside the control; CSS toggles visibility.
<label class="checkbox">
<input type="checkbox" class="checkbox__input focus-visible" id="agree">
<span class="checkbox__control"><i class="ph ph-check checkbox__icon checkbox__icon--check" style="font-size:16px" aria-hidden="true"></i><i class="ph ph-minus checkbox__icon checkbox__icon--minus" style="font-size:16px" aria-hidden="true"></i></span>
<span class="body-medium">I agree</span>
</label>
Interactive examples
Real inputs with labels. Indeterminate is set in JS on this site (data-pdoc-indeterminate).
Checkbox visuals (spec)
Static span.checkbox__control modifiers for documentation only. Each block lists interaction states without nested scroll.
Unchecked
Empty box before selection.
- Default
- Focus
- Hover
- Disabled
- Error
Selected
Checked with check icon.
- Default
- Focus
- Hover
- Disabled
- Error
Indeterminate
Partial selection (minus icon).
- Default
- Focus
- Hover
- Disabled
- Error
Radio buttons
Only one option per name. Use <fieldset> and <legend> for the group label.
<fieldset>
<legend>Shipping</legend>
<label class="radio">
<input type="radio" name="ship" class="radio__input focus-visible" id="ship-std" value="standard" checked="">
<span class="radio__control"><span class="radio__dot"></span></span>
<span class="body-medium">Standard</span>
</label>
</fieldset>
Interactive radio group
Radio visuals (spec)
Active (selected)
Filled dot when checked.
- Default
- Focus
- Hover
- Disabled
Inactive
Empty circle before selection.
- Default
- Focus
- Hover
- Disabled
Switches
Use .switch with role="switch" and sync aria-checked when the knob moves. Under the hood it is still a checkbox input.
<label class="switch">
<input type="checkbox" class="switch__input focus-visible" id="notify" role="switch" aria-checked="false">
<span class="switch__control"><span class="switch__knob"></span></span>
<span class="body-medium">Notifications</span>
</label>
Interactive switches
Switch visuals (spec)
On
Knob aligned end, action surface fill.
- Default
- Focus
- Hover
- Disabled
Off
Knob at start, neutral track.
- Default
- Focus
- Hover
- Disabled
Class reference
| Class | Description |
|---|---|
.checkbox / .radio / .switch | Label wrapper (click target) |
.*__input | Visually hidden native input |
.*__control | Visible control; doc modifiers --focus, --hover, … |
.checkbox--error | Error group; pair with aria-invalid |
.*__text--pill | Optional pill label when selected |
.switch__control--on | Doc-only “on” track (prefer :checked in apps) |
Customize (Sass)
-
Control size
Checkbox and radio use 1.5rem (24px) in component SCSS. Switch track is 3rem × 1.625rem.// scss/components/_checkbox.scss $control-size: 1.5rem; -
Rebuild CSS
Run after editing component SCSS.npm run build:css
Accessibility (RGAA / WCAG)
Selection controls
- Checkbox / switch label, native
<label>wrapping input + control + text. - Radio groups,
fieldset+ visiblelegend; samenameon every option. - Switch,
role="switch"andaria-checkedupdated on toggle (wired on this docs site). - Indeterminate, set
input.indeterminate = truein JS; not an HTML attribute alone. - Error,
.checkbox--error+aria-invalid="true"when validation fails. - Focus, keyboard users get
:focus-visiblering on__control.