@akhatmirzo/ui

RadioGroup

Pick one option from a set — native radios, arrow-key navigation and a card style.

Import

import { Radio, RadioGroup } from '@akhatmirzo/ui';

When to use

  • To pick one of 2–5 options — payment method, delivery type, plan. Every option stays visible, which makes comparing easy.
  • With many options (more than 6), a Select or Combobox saves space.
  • If several can be picked, use Checkbox.
  • When options need a price or a note, use variant="card": each option becomes a large clickable card.
  • Give the group a name — via the Field label or aria-label.

Orientation

orientation="vertical" (default) stacks options. horizontal puts them in a row and wraps when space runs out. Best for short labels.

Sizes

Set size on the group and every radio follows: sm is 16px, md (default) is 20px.

Card variant

With variant="card", each Radio becomes a bordered card that is highlighted in primary when selected. Great for prices, plans and payment methods: the label and description get plenty of room.

Tanlangan tarif: pro

States

Put disabled on the whole group or on a single Radio. invalid turns the circles' borders red and sets aria-invalid on the group and radios.

With Field

Inside a Field, the group is linked to the label with aria-labelledby, the hint and error go into aria-describedby, and required, disabled and the error state pass down to the radios.

Usulni tanlang

Props

RadioGroup

RadioGroup accepts every other <div> attribute (aria-label, className ...).

PropTypeDefaultDescription
valuestring—Controlled value
defaultValuestring—Initial value (uncontrolled)
onValueChange(value: string) => void—Called when another option is selected
orientation'vertical' | 'horizontal''vertical'Layout and aria-orientation
variant'default' | 'card''default'card turns each option into a clickable card
size'sm' | 'md''md'Circle size: 16 / 20px
namestring—Shared name for the native radios (generated if omitted)
disabledboolean—Disables the whole group
requiredboolean—A choice is required
invalidboolean—Error state (automatic inside a Field with an error)

Radio

Radio accepts the remaining <input> attributes; ref points to the inner <input> and className goes to the root <label>. It only works inside a RadioGroup.

PropTypeDefaultDescription
valuerequiredstring—Option value
labelReactNode—Text next to the circle
descriptionReactNode—Hint under the label
disabledboolean—Disables just this option
classNamestring—Class for the root <label>

Data attributes

ElementAttributes
RadioGroupdata-orientation, data-variant, data-size, data-invalid, data-disabled
Radiodata-state (checked · unchecked), data-disabled

Accessibility

  • Native radios sharing one name, so keyboard behavior comes from the browser: Tab moves into and out of the group, ↑↓ / ←→ move between options and select them.
  • role="radiogroup" with aria-orientation; inside a Field, the name comes from the label via aria-labelledby.
  • States are exposed on the group with aria-required, aria-disabled and aria-invalid.
  • Descriptions are linked to each radio with aria-describedby.
  • In the card variant, the focus ring wraps the whole card.

On this page