RadioCard

RadioCard is a component used for allowing users to select one option from multiple choices.

Usage

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

Using items

Change Variant

Change Size

Change Color Scheme

Set Default Value

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

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", "center", or "end". 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 invalid, set invalid to true.

Customize Border Color

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

Control

Props

Accessibility

The RadioCard follows the WAI-ARIA - Radio Pattern for accessibility.

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

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

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

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

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

Keyboard Navigation

KeyDescriptionState
TabMoves focus to the checked radio button within the radio group. If no radio button is checked, moves focus to the first radio button.-
SpaceChecks the focused radio button.-
ArrowLeftChecks the previous enabled radio button.-
ArrowRightChecks the next enabled radio button.-
ArrowUpChecks the previous enabled radio button.-
ArrowDownChecks the next enabled radio button.-

ARIA Roles and Attributes

ComponentRole and AttributeUsage
RadioCardGroup.Rootrole="radiogroup"Indicates that this is a radio group.
aria-labelledbyIf RadioCardGroup.Root is within a Field.Root and Field.Root has a label or Field.Label, set its id.
aria-describedbyIf RadioCardGroup.Root is within a Field.Root and Field.Root has an errorMessage, helperMessage, or a Field.ErrorMessage, Field.HelperMessage, sets its id.
RadioCard.Root, RadioCardGroup.Item.Rootaria-checkedSets to "true" if the radio button is checked, and "false" if it is not checked.
aria-describedbyIf RadioCard.Root or RadioCardGroup.Item.Root is within a Field.Root and Field.Root has an errorMessage, helperMessage, or a Field.ErrorMessage, Field.HelperMessage, sets its id.
aria-disabledSets to "true" if disabled or readOnly is set.
aria-invalidSets to "true" if invalid is set.
aria-requiredSets to "true" if required is set.
RadioIndicatoraria-hiddenExcludes the element from the accessibility tree.