CheckboxCard

CheckboxCard is a component used for allowing users to select multiple values from multiple options.

Usage

import { CheckboxCard, CheckboxCardGroup } from "@yamada-ui/react"
<CheckboxCardGroup.Root>
  <CheckboxCardGroup.Item.Root>
    <CheckboxCardGroup.Item.Label />
    <CheckboxCardGroup.Item.Description />
    <CheckboxCardGroup.Item.Addon />
  </CheckboxCardGroup.Item.Root>
</CheckboxCardGroup.Root>

Use Items

Change Variant

Change Size

Change Color Scheme

Set Default Value

To set a default value, set the value to defaultValue.

Limit the Number of Selections

To limit the number of selections, set a number to max.

Change Orientation

To change the orientation, set orientation to "horizontal" or "vertical". By default, "horizontal" is set.

Change Shape

Change Alignment

To change the alignment, set justify to "start" or "end", etc. By default, "start" is set.

Add Addon

To add an addon, set ReactNode to addon.

Hide Indicator

To hide the indicator, set withIndicator to false.

Disable

To disable, set disabled to true.

Read-Only

To make read-only, set readOnly to true.

Invalid

To make the input invalid, set invalid to true.

Customize Border Color

To customize the border color, set a value to focusBorderColor or errorBorderColor.

Customize Icon

To customize the icon, set ReactNode to checkedIcon.

Control

Props

Accessibility

The CheckboxCard follows the WAI-ARIA - Checkbox Pattern for accessibility.

If you are not using Field.Root, set aria-label or aria-labelledby to CheckboxCardGroup.Root.

const items = useMemo<CheckboxCardGroup.ItemType[]>(
  () => [
    { label: "ビアンカ", value: "1" },
    { label: "フローラ", value: "2" },
    { label: "ルドマン", value: "3" },
  ],
  [],
)

return <CheckboxCardGroup.Root aria-label="キャラクター" items={items} />
const items = useMemo<CheckboxCardGroup.ItemType[]>(
  () => [
    { label: "ビアンカ", value: "1" },
    { label: "フローラ", value: "2" },
    { label: "ルドマン", value: "3" },
  ],
  [],
)

return (
  <VStack gap="sm">
    <Text as="h3" id="label">
      キャラクター
    </Text>

    <CheckboxCardGroup.Root aria-labelledby="label" items={items} />
  </VStack>
)

Keyboard Navigation

KeyDescriptionState
SpaceToggles the checked state of the checkbox.-

ARIA Roles and Attributes

ComponentRoles and AttributesUsage
CheckboxCardGroup.Rootrole="group"Indicates that it's a group.
aria-labelledbyIf CheckboxCardGroup.Root is within a Field.Root and Field.Root has a label or Field.Label, sets its id.
aria-describedbyIf CheckboxCardGroup.Root is within a Field.Root and Field.Root has an errorMessage, helperMessage, or a Field.ErrorMessage, Field.HelperMessage, sets its id.
inputaria-checkedSets to "mixed" if indeterminate is set, "true" if checked, and "false" if unchecked.
aria-disabledSets to "true" if readOnly is set, or if max is reached in a group.
aria-invalidSets to "true" if invalid is set.
aria-requiredSets to "true" if required is set.
CheckboxCardIndicatoraria-hiddenExcludes the element from the accessibility tree.