Examples

States

Preview

Sent every Monday at 9:00.

Required to continue.

Example.tsx
import { Checkbox, Stack } from '@reactloom/ui';

export default function Example() {
  return (
    <Stack gap="3">
      <Checkbox label="Email me product updates" defaultChecked />
      <Checkbox label="Weekly usage report" description="Sent every Monday at 9:00." />
      <Checkbox label="Accept the data processing agreement" error="Required to continue." />
      <Checkbox label="SSO enforcement (Enterprise)" disabled />
    </Stack>
  );
}

Group

A fieldset and legend with a shared value array.

Preview
Notify me about

Choose at least one.

Example.tsx
import { Checkbox, CheckboxGroup } from '@reactloom/ui';

export default function Example() {
  return (
    <CheckboxGroup legend="Notify me about" description="Choose at least one." defaultValue={['invoices']}>
      <Checkbox value="invoices" label="New invoices" />
      <Checkbox value="payments" label="Failed payments" />
      <Checkbox value="seats" label="Seat limit reached" />
    </CheckboxGroup>
  );
}

Select all

indeterminate maps to aria-checked="mixed".

Preview
Billing events
Example.tsx
import { Checkbox, CheckboxGroup, Stack } from '@reactloom/ui';
import { useState } from 'react';

const events = ['Invoices', 'Payments', 'Refunds', 'Disputes'];

export default function Example() {
  const [selected, setSelected] = useState(['Invoices']);
  const all = selected.length === events.length;
  return (
    <Stack gap="2">
      <Checkbox
        label="All billing events"
        checked={all}
        indeterminate={selected.length > 0 && !all}
        onCheckedChange={(checked) => setSelected(checked ? events : [])}
      />
      <CheckboxGroup legend="Billing events" hideLabel value={selected} onValueChange={setSelected} style={{ paddingInlineStart: 24 }}>
        {events.map((e) => (
          <Checkbox key={e} value={e} label={e} />
        ))}
      </CheckboxGroup>
    </Stack>
  );
}

API reference

Checkbox props

Checkbox props
PropTypeDefault
label
ReactNode—
description · error · invalid
ReactNode · boolean—
checked / defaultChecked
boolean—
onCheckedChange
(checked: boolean) => void—
indeterminate
booleanfalse
size
'sm' | 'md' | 'lg''md'
value · name · required
Native form attributes.
—

CheckboxGroup props

CheckboxGroup props
PropTypeDefault
legend
The group’s accessible name.
ReactNode—
value / defaultValue
string[]—
onValueChange
(value: string[]) => void—
name
Submitted name for each box.
string—
orientation
'vertical' | 'horizontal''vertical'
description · error
Linked to the group.
ReactNode—

Customization

Extracted from the component’s source on every build, so it matches the code. How the layers fit together is explained in Customization.

State attributes

Target these in your CSS to style states without depending on class names.

AttributeValues
[data-disabled]present when on
[data-invalid]present when on
[data-size]present when on
[data-type]present when on

Theme tokens it reads

--pl-color-accent-solid --pl-color-bg-muted --pl-color-bg-subtle --pl-color-bg-surface --pl-color-border-default --pl-color-border-input --pl-color-danger-border --pl-color-fg-default --pl-color-fg-disabled --pl-color-fg-muted --pl-color-fg-on-accent --pl-focus-ring-color --pl-focus-ring-offset --pl-focus-ring-width --pl-font-size-lg --pl-font-size-md --pl-font-size-sm --pl-radius-xs

Accessibility

  • Real inputs: works with forms, FormData, required validation and browser autofill.
  • The whole label row is clickable; indicators meet 3:1 contrast.
Keyboard interactions
KeyAction
SpaceToggle
TabNext checkbox

Usage guidelines

Do

  • Use checkboxes for independent choices submitted with a form.

Don’t

  • Don’t use a checkbox for settings that apply immediately — use Switch.