0.1.0-rc.2

Checkbox

Checkboxes toggle independent options on or off. Use them when each choice is unrelated and more than one can be selected.

Try it

Usage

Wrap a checkbox in RuiField with RuiLabel for consistent spacing and error display. Bind checked for controlled state.

import { RuiCheckbox } from '@ecopages/radiant-ui/checkbox';
import { RuiField } from '@ecopages/radiant-ui/field';
import { RuiLabel } from '@ecopages/radiant-ui/label';
 
<RuiField name="newsletter">
  <RuiLabel>Email me product updates</RuiLabel>
  <RuiCheckbox checked={subscribed} value="yes" />
</RuiField>

Indeterminate selections

Set indeterminate when a parent checkbox represents a partially selected group. Clear indeterminate once the user makes an explicit choice.

Wire through RuiField

Pass name on RuiField so the checkbox participates in RuiForm validation and submission.

Theming

Checkbox chrome maps to semantic surface roles, never Tailwind palette steps:

Part / stateCSS roles
Box (rui-checkbox__control)border, background, rounded-control
Checked boxprimary fill, on-primary check glyph
Indeterminate barprimary on background
Focusfocus-ring
Disabledopacity-disabled

Label text uses on-background. Override roles at the theme layer, not in component CSS.

Accessibility

  • Every checkbox needs a visible label; use RuiLabel or aria-label.
  • Indeterminate state is exposed with aria-checked="mixed".
  • Disabled checkboxes should include context explaining why the option is unavailable.

API

RuiCheckbox is a custom element (<rui-checkbox>) rendering a native <input type="checkbox"> inside a <label>, the browser owns activation and Space-to-toggle.

Attributes (<rui-checkbox>)

AttributeTypeDefaultDescription
checkedbooleanfalseChecked state.
indeterminatebooleanfalsePartially checked (mixed) state; sets indeterminate IDL + aria-checked="mixed".
disabledbooleanfalseDisabled state.
valuestringonValue submitted with forms when checked.
namestring''Form field name.

Slots

SlotDescription
(default)Visible label for the checkbox.

Events

EventDetailDescription
rui-change{ checked: boolean, indeterminate: boolean }Emitted after the state changes.

CSS classes

Public BEM classes (documented via @cssclass):

ClassDescription
.rui-checkboxLabel row: box + visible label.
.rui-checkbox__inputNative input (visually hidden, receives focus).
.rui-checkbox__controlVisible box with check / indeterminate glyph.
.rui-checkbox__labelLight-DOM label text.

Theme roles

PartCSS variables consumed
Box--border, --background
Checked--primary, --on-primary
Indeterminate--primary
Focus ring--focus-ring