Radio

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

Usage

import { Radio, RadioGroup } from "@yamada-ui/react"
<RadioGroup.Root>
  <RadioGroup.Item />
</RadioGroup.Root>

Use Items

Change Variant

Change Size

Set Default Value

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

Default Checked

To default checked, set defaultChecked to true.

Change Direction

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

Change Shape

To change the shape, set shape to "circle", "square" or "rounded". The default is "circle".

Disable

To disable, set disabled to true.

Read-Only

To read-only, set readOnly to true.

Invalid

To make invalid, set invalid to true.

Change Border Color

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

Control

Use Custom Component

Props

Accessibility

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

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

<RadioGroup.Root aria-label="キャラクター">
  <RadioGroup.Item value="孫悟空">孫悟空</RadioGroup.Item>
  <RadioGroup.Item value="ベジータ">ベジータ</RadioGroup.Item>
  <RadioGroup.Item value="フリーザ">フリーザ</RadioGroup.Item>
</RadioGroup.Root>
<VStack gap="sm">
  <Text as="h3" id="label">
    キャラクター
  </Text>

  <RadioGroup.Root aria-labelledby="label">
    <RadioGroup.Item value="孫悟空">孫悟空</RadioGroup.Item>
    <RadioGroup.Item value="ベジータ">ベジータ</RadioGroup.Item>
    <RadioGroup.Item value="フリーザ">フリーザ</RadioGroup.Item>
  </RadioGroup.Root>
</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

ComponentRoles and AttributesUsage
RadioGroup.Rootrole="radiogroup"Indicates that this is a radio group.
aria-labelledbyIf RadioGroup.Root is within a Field.Root and Field.Root has a label or Field.Label, sets its id.
aria-describedbyIf RadioGroup.Root is within a Field.Root and Field.Root has an errorMessage, helperMessage, or a Field.ErrorMessage, Field.HelperMessage, sets its id.
Radio, RadioGroup.Itemaria-checkedSets to "true" if the radio button is checked, and "false" if it is not checked.
aria-describedbyIf Radio or RadioGroup.Item 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.