Phoundry UI

Checkbox

Checkbox with label and indeterminate state. Accessible via keyboard (Space/Enter) with support for form integration.

import { Checkbox } from 'phoundry-ui';

Basic toggle

Unchecked
Show code
<Checkbox checked={value} onchange={() => value = !value} />

With label and description

You agree to our privacy policy
Show code
<Checkbox
  checked={value}
  onchange={() => value = !value}
  label="Accept terms and conditions"
  description="You agree to our privacy policy"
/>

Indeterminate state

Some items are selected
Show code
<Checkbox
  checked={false}
  indeterminate={indeterminate}
  onchange={() => indeterminate = false}
  label="Select all"
/>

Sizes

Show code
<Checkbox checked={v} onchange={...} size="sm" label="Small" />
<Checkbox checked={v} onchange={...} size="md" label="Medium" />

Form name (hidden input)

With name, a hidden <input type="checkbox"> mirrors state for native submission. Keep id in sync with external labels if you do not use the built-in label.

Show code
<form method="post">
  <Checkbox checked={agree} onchange={...} name="terms" label="I agree" />
</form>

Disabled

Show code
<Checkbox checked={true} disabled label="Disabled (checked)" />
<Checkbox checked={false} disabled label="Disabled (unchecked)" />

Props

PropTypeDefaultDescription
checked requiredbooleanWhether the checkbox is checked
onchange () => voidCalled when the checkbox is toggled
indeterminate booleanfalseShows a dash icon instead of a checkmark (mixed state)
disabled booleanfalsePrevents interaction
size 'sm' | 'md''sm'Indicator box (~14px sm / ~16px md display size, not full control height)
label string | SnippetInline label rendered next to the checkbox
description stringHelper text below the label
class stringAdditional CSS classes
id stringElement id (auto-generated if omitted)
name stringForm field name — renders a hidden input
element HTMLButtonElementBindable reference to the checkbox button.
...rest Record<string, unknown>Additional attributes forwarded to the checkbox `<button>` (e.g. `aria-invalid`, `data-testid`).

Usage tips

  • Use indeterminate for “select all” patterns where only some children are checked.
  • Pass a name prop to render a hidden <input> for native form submission.
  • When using without the label prop, wrap in your own <label> for accessibility.