Tally UI
UI

RadioGroup

A styled set of mutually exclusive options, built on the RadioGroup primitive.

Import

import { RadioGroup, RadioGroupItem } from '@tallyui/components';

Usage

<RadioGroup value={value} onValueChange={setValue}>
  <RadioGroupItem value="option-1" />
  <RadioGroupItem value="option-2" />
  <RadioGroupItem value="option-3" />
</RadioGroup>

RadioGroup and RadioGroupItem are pre-styled wrappers around RadioGroup.Root, RadioGroup.Item, and RadioGroup.Indicator from @tallyui/primitives. Each item renders a filled circle indicator when selected. See the RadioGroup primitive for behavior and accessibility details.

Default Styling

PartStateClasses
RootBasegrid gap-2
ItemBaseaspect-square h-4 w-4 rounded-full border border-primary text-primary
ItemDisabledopacity-50 web:cursor-not-allowed
ItemFocus (web)ring-2 ring-ring ring-offset-2 ring-offset-background
IndicatorBaseflex items-center justify-center
Indicator dotBaseh-2.5 w-2.5 rounded-full bg-current

Props

RadioGroup

PropTypeDefaultDescription
valuestring---Controlled selected value
defaultValuestring---Initial value (uncontrolled)
onValueChange(value: string) => void---Called when selection changes
disabledbooleanfalseDisables all items
classNamestring---Additional NativeWind classes merged via cn()

Plus all React Native ViewProps.

RadioGroupItem

PropTypeDefaultDescription
valuestringrequiredThe value this item represents
disabledbooleanfalseDisables this individual item
classNamestring---Additional NativeWind classes merged via cn()

Plus all React Native PressableProps.

Examples

With labels

import { useState } from 'react';
import { View } from 'react-native';
import { RadioGroup, RadioGroupItem, Label, Text } from '@tallyui/components';

function SizeSelector() {
  const [size, setSize] = useState('medium');

  return (
    <RadioGroup value={size} onValueChange={setSize}>
      {['small', 'medium', 'large'].map((s) => (
        <View key={s} className="flex-row items-center gap-2">
          <RadioGroupItem value={s} nativeID={s} />
          <Label nativeID={s}>
            <Text className="capitalize">{s}</Text>
          </Label>
        </View>
      ))}
    </RadioGroup>
  );
}

Disabled items

<RadioGroup defaultValue="free">
  <View className="flex-row items-center gap-2">
    <RadioGroupItem value="free" />
    <Text>Free</Text>
  </View>
  <View className="flex-row items-center gap-2">
    <RadioGroupItem value="pro" disabled />
    <Text className="text-muted-foreground">Pro (coming soon)</Text>
  </View>
  <View className="flex-row items-center gap-2">
    <RadioGroupItem value="enterprise" />
    <Text>Enterprise</Text>
  </View>
</RadioGroup>

On this page