Usage
import { CheckboxCard } from "chakra-ui-solid";<CheckboxCard.Root>
<CheckboxCard.HiddenInput />
<CheckboxCard.Control>
<CheckboxCard.Content>
<CheckboxCard.Label />
<CheckboxCard.Description />
</CheckboxCard.Content>
<CheckboxCard.Indicator />
</CheckboxCard.Control>
</CheckboxCard.Root>CheckboxCard.Root renders the <label> and CheckboxCard.HiddenInput renders the real
<input type="checkbox"> inside it, so a click anywhere on the card toggles it. The input is not
optional — without it there is nothing focusable, nothing to submit, and nothing for the label to
point at.
It runs the same machine Checkbox does, so everything a checkbox composes with a checkbox card
composes with too: CheckboxGroup, Field.Root and Fieldset.Root.
If you prefer a closed component composition, check out the snippet below.
Examples
Description
Use the CheckboxCard.Description component to add a description to the checkbox card.
Group
Use the CheckboxGroup component to group multiple checkbox cards.
Select framework(s)
Sizes
Pass the size prop to the CheckboxCard.Root component to change the size of the checkbox card.
Variants
Pass the variant prop to the CheckboxCard.Root component to change the variant of the checkbox
card.
Disabled
Pass the disabled prop to the CheckboxCard.Root component to make the checkbox card disabled.
Addon
Render additional content within the CheckboxCard.Addon component to add some more context to the
checkbox card.
No Indicator
Here’s an example of how to use the checkbox card without an indicator.
Icon
Here’s an example of how to render custom icons within the checkbox card.
Closed Component
Here’s how to setup the Checkbox card for a closed component composition.
Guides
CheckboxGroup + Field vs Fieldset
When working with multiple checkbox cards, it’s important to understand the semantic difference
between Field and Fieldset:
- Single CheckboxCard: Can be wrapped with
Field.Rootfor proper form field structure with labels and helper text - CheckboxGroup: Should be wrapped with
Fieldset.Root, notField.Root
A group of checkbox cards represents a collection of related options and should be marked up as a
fieldset with a legend, not as a single field. Wrapping CheckboxGroup in Field.Root can cause
interaction issues where only the first checkbox card responds to clicks.
✅ Correct Usage:
<Fieldset.Root>
<CheckboxGroup name="framework">
<Fieldset.Legend>Select framework(s)</Fieldset.Legend>
{/* ... checkbox cards ... */}
</CheckboxGroup>
</Fieldset.Root>❌ Incorrect Usage:
// Don't wrap CheckboxGroup with Field.Root
<Field.Root>
<CheckboxGroup>{/* ... checkbox cards ... */}</CheckboxGroup>
</Field.Root>Styling the box
The tick’s box — the border, the radius, the fill and its size — is on the indicator slot, which is
the opposite of Checkbox, where the box lives on Checkbox.Control. Style CheckboxCard.Indicator
to change how the tick looks and CheckboxCard.Control to change the card around it.
<CheckboxCard.Indicator borderRadius="full" />Props
Root
| Prop | Default | Type |
|---|---|---|
align | 'start' | ConditionalValue<'start' | 'end' | 'center' | PresetVariant<'checkboxCard', 'align'>>Where they sit across it, and how the content's own text is aligned. |
checked | — | checkbox.CheckedStateThe controlled checked state. Pass `undefined` for uncontrolled. |
defaultChecked | — | checkbox.CheckedStateThe state a fresh, uncontrolled checkbox starts in. |
disabled | — | booleanWhether the checkbox can be toggled or focused at all. Inherited from a surrounding Field. |
form | — | stringThe id of a form elsewhere on the page that this checkbox submits with. |
id | — | stringSeeds every id the machine hands out — the root is `checkbox:{id}`, the hidden input `checkbox:{id}:input`. Defaults to a generated id, and **does not become the root element's own `id`**: pass `ids` to control the attributes themselves. |
ids | — | CheckboxElementIdsOverride individual element ids, for pointing an ARIA relationship at a specific one. |
invalid | — | booleanWhether the checkbox shows its error treatment. Inherited from a surrounding Field. |
justify | — | ConditionalValue<'start' | 'end' | 'center' | PresetVariant<'checkboxCard', 'justify'>>Where the control and the content sit along the main axis. Unset by default. |
name | — | stringThe hidden input's `name`, for form submission. |
onCheckedChange | — | (details: CheckboxCheckedChangeDetails) => voidCalled whenever the checked state changes, from either side. |
orientation | 'horizontal' | ConditionalValue<'vertical' | 'horizontal' | PresetVariant<'checkboxCard', 'orientation'>>Whether the control stacks its children in a row or a column. |
readOnly | — | booleanWhether the checkbox refuses to change while staying focusable. Inherited from a Field. |
required | — | booleanWhether the form requires this box to be ticked. Inherited from a surrounding Field. |
size | 'md' | ConditionalValue<'sm' | 'md' | 'lg' | PresetVariant<'checkboxCard', 'size'>>The card's padding, its inner gap, the label's text style and the indicator's box. |
value | 'on' | stringThe hidden input's `value`, for form submission — and the key a `<CheckboxGroup>` tracks this box by. |
variant | 'outline' | ConditionalValue<'surface' | 'subtle' | 'outline' | 'solid' | PresetVariant<'checkboxCard', 'variant'>>How the card and its indicator are painted, at rest and once ticked. |
Plus Omit<HTMLChakraProps<"label">, "id"> — the whole style-prop surface and the DOM attributes of the element it renders, several hundred names listed as their sources rather than expanded — and the three every component takes: as, render and unstyled.
RootProvider
| Prop | Default | Type |
|---|---|---|
align | 'start' | ConditionalValue<'start' | 'end' | 'center' | PresetVariant<'checkboxCard', 'align'>>Where they sit across it, and how the content's own text is aligned. |
justify | — | ConditionalValue<'start' | 'end' | 'center' | PresetVariant<'checkboxCard', 'justify'>>Where the control and the content sit along the main axis. Unset by default. |
orientation | 'horizontal' | ConditionalValue<'vertical' | 'horizontal' | PresetVariant<'checkboxCard', 'orientation'>>Whether the control stacks its children in a row or a column. |
size | 'md' | ConditionalValue<'sm' | 'md' | 'lg' | PresetVariant<'checkboxCard', 'size'>>The card's padding, its inner gap, the label's text style and the indicator's box. |
value* | — | CreateCheckboxCardReturnA machine built by {@link createCheckboxCard}, so the consumer owns it rather than the Root. |
variant | 'outline' | ConditionalValue<'surface' | 'subtle' | 'outline' | 'solid' | PresetVariant<'checkboxCard', 'variant'>>How the card and its indicator are painted, at rest and once ticked. |
Plus HTMLChakraProps<"label"> — the whole style-prop surface and the DOM attributes of the element it renders, several hundred names listed as their sources rather than expanded — and the three every component takes: as, render and unstyled.