Skip to main content
PimentCSS v1.0.1, what's new
Home

Checkboxes, radios & switches

Selection controls with accessible labels and group semantics.

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.

HTMLPimentCSSDoc
input[type="text|email|tel|…"].field + .field__inputInput fields
textarea.textarea + .textarea-fieldInput fields
select.field + select.field__inputInput fields
input[type="checkbox"].checkboxThis page
input[type="radio"].radio + fieldsetThis page
role="switch".switchThis page
Custom listbox.dropdown + .menuMenu & dropdown
ControlSourceNotes
Checkboxscss/components/_checkbox.scssChecked, indeterminate, error
Radioscss/components/_radio.scssOne name per group
Switchscss/components/_switch.scssrole="switch", aria-checked

Prerequisites

  • PimentCSS installed, Installation.
  • Input fields, labels and hints from Input fields.
  • Focus, :focus-visible rings 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.

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.

Interactive radio group

Notification channel

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.

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

ClassDescription
.checkbox / .radio / .switchLabel wrapper (click target)
.*__inputVisually hidden native input
.*__controlVisible control; doc modifiers --focus, --hover, …
.checkbox--errorError group; pair with aria-invalid
.*__text--pillOptional pill label when selected
.switch__control--onDoc-only “on” track (prefer :checked in apps)

Customize (Sass)

  1. 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;
  2. 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 + visible legend; same name on every option.
  • Switch, role="switch" and aria-checked updated on toggle (wired on this docs site).
  • Indeterminate, set input.indeterminate = true in JS; not an HTML attribute alone.
  • Error, .checkbox--error + aria-invalid="true" when validation fails.
  • Focus, keyboard users get :focus-visible ring on __control.

Next steps