Checkbox card
A checkbox presented as a selectable card, for options that need a title and a short description.
<CheckboxCard />The card draws its own indicator. You provide the content as children.
When to use
- When each option needs a title and a description, such as notification types.
- When the options are few and the whole card should be easy to hit.
- In generated forms, where a checkbox field needs a larger target and room for help text.
When not to use
- A plain option with a short label. Use Checkbox.
- Choosing exactly one option. Use Radio card.
- A setting that applies immediately. Use Switch.
- Long lists. Use Checkbox in a list. Cards take too much space.
States
Selected cards get a solid tertiary background and a tertiary border. The strong outline is reserved for keyboard focus.
Read only
Examples
Group of options
Wrap the cards in an element with role="group" and an accessible name.
Content
- Start with a title that names the option: “Prazo próximo do vencimento”.
- Use the description for what happens when it is selected, in one sentence.
- Build the content with
Typographyspans. Do not put buttons or links inside the card: the whole card is one control.
Do and don’t
Accessibility
- Built on Radix Checkbox: the whole card is one
buttonwithrole="checkbox"andaria-checkedset totrue,falseor"mixed". Spacetoggles the card. The card has no label element: its text content is the accessible name. Usearia-labelledbyandaria-describedbyto point at the title and the description.- The focus ring appears only for keyboard focus (
focus-visible). The indicator icon is hidden from assistive technology (aria-hidden). - Selection is shown by a check or a minus inside the box, so it does not rely on color alone.
aria-readonlyonly changes the style: Radix still toggles the card. Ignore the change inonCheckedChange.
Code
import { CheckboxCard } from "@repo/ui/checkbox-card";
import { Typography } from "@repo/ui/typography";
<CheckboxCard checked={checked} onCheckedChange={setChecked}>
<Typography as="span" variant="labelSm">
Devolução de contestação
</Typography>
</CheckboxCard>;
Props
CheckboxCard| Prop | Type | Default | Description |
|---|---|---|---|
checked | boolean | "indeterminate" | — | Controlled state: `true`, `false` or `"indeterminate"` (a mixed selection) |
children | ReactNode | — | The card content. Compose a title and a description, and avoid nested interactive controls |
disabled | boolean | false | Disables interaction and dims the card |
onCheckedChange | (checked: boolean | "indeterminate") => void | — | Called with the new state when the user toggles |
Every other prop of the Radix Checkbox root, such as name, value and
required, is forwarded. asChild is not available.
Known issues
| Issue | Effect |
|---|---|
Disabled is disabled:opacity-50 on the whole card. |
A translucent card, against the no-transparency rule. The text contrast can fall below AA. |
aria-readonly is styled but not enforced. |
A read-only card still toggles unless the app ignores the change. |
No style for aria-invalid. |
A card cannot show a validation error. |
The focus ring has ring-offset-2 with no offset color token. |
The offset falls back to Tailwind’s default, white. |