Skip to Content

Built by moveinready.casa  and the community

Shadcn Docs

Radix Docs

Radio Group

A set of checkable items—known as radio items—where no more than one of the items can be checked at a time.

Usage

import {Text} from "react-native"; import {RadioGroup, RadioGroupItem} from "@/components/ui/radio-group"; <RadioGroup value={value} onValueChange={setValue} orientation="vertical"> <RadioGroupItem value="apple"> <Text>Apple</Text> </RadioGroupItem> <RadioGroupItem value="banana"> <Text>Banana</Text> </RadioGroupItem> <RadioGroupItem value="cherry"> <Text>Cherry</Text> </RadioGroupItem> </RadioGroup>;

Components

RadioGroup

PropTypeDefaultDescription
valuestring-Controlled value of the selected radio item. Use with onValueChange.
defaultValuestring-Uncontrolled initial value of the selected radio item.
onValueChange(value: string) => void-Callback when the selected value changes.
disabledbooleanfalseWhether all radio items are disabled.
namestring-Group name (forwarded on web).
requiredbooleanfalseWhether selection is required (forwarded on web).
orientation"horizontal" | "vertical""vertical"Lays out the group horizontally or vertically.
dir"ltr" | "rtl"-Reading direction (forwarded on web).
loopboolean-Whether keyboard navigation loops (forwarded on web).
asChildbooleanfalseIf true, clones the child and passes all accessibility and functionality props to it.
baseClassNamestring-Custom tailwind classes to apply to the base group container. Takes priority over the className prop.

Also extends all React Native View component props.

RadioGroupItem

PropTypeDefaultDescription
valuestring-The value of the radio item.
disabledbooleanfalseWhether this radio item is disabled. Overrides the top-level RadioGroup disabled when set.
asChildbooleanfalseIf true, clones the child and passes all accessibility and functionality props to it.
baseClassNamestring-Custom tailwind classes to apply to the base radio item. Takes priority over the className prop.
labelClassNamestring-Custom tailwind classes to apply to the label.
controlClassNamestring-Custom tailwind classes to apply to the radio control.
indicatorClassNamestring-Custom tailwind classes to apply to the radio indicator.

Also extends all React Native Pressable component props.

Accessibility

The Radio Group is built with accessibility in mind and includes:

Web Accessibility

  • Uses role="radiogroup" for the group, and role="radio" for items
  • Supports ARIA attributes: aria-checked, aria-disabled, and aria-required
  • Keyboard navigation support via arrow keys with optional looping
  • Integrates with React Aria useRadioGroup for proper semantics and labeling

React Native Accessibility

  • Uses accessibilityRole="radiogroup" for the group and accessibilityRole="radio" for each item
  • accessibilityState is set appropriately with selected and disabled
  • Labels can be provided via children or external Text components

Styling

RadioGroup Classes

Slots:

  • base - For the base View in the radio group component

Variants:

  • orientation:
    • vertical (default) - flex-col
    • horizontal - flex-row

Base Classes: flex gap-2

RadioGroupItem Classes

Slots:

  • base - For the item container
  • control - For the radio control element
  • indicator - For the inner selected indicator
  • label - For the text label

Variants:

  • selected - When true, indicator uses bg-secondary-foreground
  • disabled - When true, item uses opacity-50
  • focused - When true, item uses ring-2 ring-ring

Base Classes:

  • base: flex flex-row items-center gap-2 px-3 py-2 rounded-md
  • control: w-4 h-4 rounded-full border border-border items-center justify-center
  • indicator: w-2 h-2 rounded-full
  • label: text-sm text-foreground

shadcn-native

Built by moveinready.casa and the community