Skip to content

Checkbox

A custom-drawn checkbox with its label, plain or as a chip.

import { Checkbox } from '@/design-system';

Examples

Plain

import { Checkbox } from '@/design-system';

export default function CheckboxPlain() {
  return <Checkbox label="Start with a free trial" defaultChecked />;
}

Chips

Chips suit filters. Group them in a fieldset with a legend.

Show only
'use client';

import { useState } from 'react';
import { Checkbox } from '@/design-system';

export default function CheckboxChip() {
  const [active, setActive] = useState<string[]>(['Vegetarian']);

  return (
    <fieldset className="flex flex-wrap gap-3">
      <legend className="mb-2 text-sm text-muted">Show only</legend>
      {['Vegetarian', 'Gluten-free'].map(filter => (
        <Checkbox
          key={filter}
          appearance="chip"
          label={filter}
          checked={active.includes(filter)}
          onChange={e =>
            setActive(list =>
              e.target.checked
                ? [...list, filter]
                : list.filter(item => item !== filter),
            )
          }
        />
      ))}
    </fieldset>
  );
}

How it works

  • The box and tick are drawn by the design system over a real checkbox, so keyboards, forms and screen readers work as usual. In forced-colour modes the system’s checkbox is shown.
  • Use defaultChecked to let the browser keep the state, or checked with onChange to keep it yourself.
  • It does not read from Field and has no built-in error message.

Props

Every other input attribute except type is passed to the checkbox.

Checkbox props
PropTypeDefaultDescription
labelReactNoderequiredShown beside the box and clickable.
appearance'plain' | 'chip''plain'A chip outlines the whole control and colours it when checked.
classNamestring—Added to the wrapping label, not the input.

Tokens

Tokens
TokenDefaultSets
--checkbox-size1.125remWidth and height of the box
--checkbox-radius0.25remCorner radius of the box
--checkbox-border--mutedBorder while unchecked
--chip-radius999pxCorner radius of a chip
--field-font-size0.875remLabel text size