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.
'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
defaultCheckedto let the browser keep the state, orcheckedwithonChangeto keep it yourself. - It does not read from
Fieldand has no built-in error message.
Props
Every other input attribute except type is passed to the checkbox.
| Prop | Type | Default | Description |
|---|---|---|---|
label | ReactNode | required | Shown beside the box and clickable. |
appearance | 'plain' | 'chip' | 'plain' | A chip outlines the whole control and colours it when checked. |
className | string | — | Added to the wrapping label, not the input. |
Tokens
| Token | Default | Sets |
|---|---|---|
--checkbox-size | 1.125rem | Width and height of the box |
--checkbox-radius | 0.25rem | Corner radius of the box |
--checkbox-border | --muted | Border while unchecked |
--chip-radius | 999px | Corner radius of a chip |
--field-font-size | 0.875rem | Label text size |