Skip to main content

Checkbox

A control for toggling a boolean value. Styled automatically by @primus/ui-core.

Preview · Checkbox

Code​

<div class="vstack" style="max-width:280px">
<label><input type="checkbox" /> Accept terms and conditions</label>
<label><input type="checkbox" checked /> Subscribe to newsletter</label>
<label><input type="checkbox" disabled /> Disabled option</label>
<div data-field="error">
<label><input type="checkbox" aria-invalid="true" /> I agree to the terms</label>
<span class="error">You must accept the terms to continue.</span>
</div>
</div>

Props​

PropTypeDefaultDescription
labelstring''Label text
checkedbooleanfalseChecked state
disabledbooleanfalseDisabled
errorstring''Error message

Accessibility​

  • Native <input type="checkbox"> — activated with Space key
  • Label text is always announced by screen readers
  • Indeterminate state: set inputRef.current.indeterminate = true (React) or [indeterminate]="true" (Angular)
  • Group checkboxes inside <fieldset> + <legend> for screen reader context
Version history

See the Changelog for version history and breaking changes.