Components

RadioGroup

Single-select group of radio button items, each with an indicator and label.

Category: Form / Composite

Dependency: @base-ui-components/react

Preview

Loading preview...
import { RadioGroup, RadioGroupItem } from "@hareru/ui"

<RadioGroup defaultValue="apple">
  <RadioGroupItem value="apple">Apple</RadioGroupItem>
  <RadioGroupItem value="banana">Banana</RadioGroupItem>
  <RadioGroupItem value="cherry">Cherry</RadioGroupItem>
</RadioGroup>

Import

import { RadioGroup, RadioGroupItem, RadioGroupItemIndicator } from "@hareru/ui"

Exports

NameTypeDescription
RadioGroupComponentRoot container with role="radiogroup"
RadioGroupItemComponentIndividual radio option (renders as <label> with implicit label association)
RadioGroupItemIndicatorComponentInner dot indicator
RadioGroupPropsTypeProps interface for RadioGroup
RadioGroupItemPropsTypeProps interface for RadioGroupItem
RadioGroupItemIndicatorPropsTypeProps interface for RadioGroupItemIndicator

Types

export interface RadioGroupProps extends React.HTMLAttributes<HTMLDivElement> {
  value?: string
  defaultValue?: string
  onValueChange?: (value: string) => void
  name?: string
  required?: boolean
  disabled?: boolean
}

export interface RadioGroupItemProps
  extends React.LabelHTMLAttributes<HTMLLabelElement> {
  value: string
  disabled?: boolean
}

Key Props

RadioGroup

PropTypeDefaultDescription
valuestringControlled selected value
defaultValuestringInitial uncontrolled selected value
onValueChange(value: string) => voidCallback when selection changes
namestringForm field name for native form submission
requiredbooleanfalseMarks the group as required
disabledbooleanfalseDisables all items in the group

RadioGroupItem

PropTypeDefaultDescription
valuestringValue for this radio option (required)
disabledbooleanfalseDisables this individual item
childrenReactNodeLabel text for this option

Structure

  • RadioGroupItem [item] (expected) ×N
    • RadioGroupItemIndicator [indicator]

(expected) = recommended in canonical composition, not runtime-required.

States

StateTypeValuesDefaultCSS Reflection
disabledboolean

Accessibility

  • Roles: radiogroup, radio
  • ARIA attributes: aria-checked
  • Keyboard:
    • Arrow keys to move between options
    • Space to select
  • Notes: ARIA radiogroup and radio roles provided by Base UI.

Usage

import { RadioGroup, RadioGroupItem } from "@hareru/ui"

// Basic usage
<RadioGroup defaultValue="apple">
  <RadioGroupItem value="apple">Apple</RadioGroupItem>
  <RadioGroupItem value="banana">Banana</RadioGroupItem>
  <RadioGroupItem value="cherry">Cherry</RadioGroupItem>
</RadioGroup>

// Controlled
<RadioGroup value={fruit} onValueChange={setFruit}>
  <RadioGroupItem value="apple">Apple</RadioGroupItem>
  <RadioGroupItem value="banana">Banana</RadioGroupItem>
</RadioGroup>

// With disabled item
<RadioGroup>
  <RadioGroupItem value="free">Free</RadioGroupItem>
  <RadioGroupItem value="pro">Pro</RadioGroupItem>
  <RadioGroupItem value="enterprise" disabled>Enterprise (coming soon)</RadioGroupItem>
</RadioGroup>

// With FormField (group mode)
<FormField group error={!!errors.fruit}>
  <FormFieldGroupLabel>Preferred fruit</FormFieldGroupLabel>
  <FormFieldControl>
    <RadioGroup value={fruit} onValueChange={setFruit}>
      <RadioGroupItem value="apple">Apple</RadioGroupItem>
      <RadioGroupItem value="banana">Banana</RadioGroupItem>
    </RadioGroup>
  </FormFieldControl>
  <FormFieldMessage>{errors.fruit?.message}</FormFieldMessage>
</FormField>

Notes

  • RadioGroupItem renders as a native <label> wrapping the radio control, providing implicit label association without needing separate Label + htmlFor.
  • RadioGroupItemIndicator is rendered internally by RadioGroupItem — you do not need to add it manually.
  • Use RadioGroup when exactly one option must be selected from a small set. Use Select for longer lists.
  • When using with FormField, use the group prop and FormFieldGroupLabel instead of FormFieldLabel (see FormField).
  • Arrow keys navigate between radio items; Space selects the focused item.

On this page