Lunar Kit LogoLunar Kit
Components

Radio

A radio button component for selecting one option from a set.

Demo
Code
Option One
Option Two

Installation

lunar add radio
# For radio groups
lunar add radio-group

Usage

Radio (Standalone)

import { Radio } from '@/components/ui/radio';
 
const [checked, setChecked] = useState(false);
 
<Radio checked={checked} onCheckedChange={setChecked}>
<Text>Option</Text>
</Radio>

RadioGroup

import {
RadioGroup,
RadioGroupItem,
RadioGroupLabel,
RadioGroupDescription,
} from '@/components/ui/radio-group';
 
const [value, setValue] = useState('option1');
 
<RadioGroup value={value} onValueChange={setValue}>
<RadioGroupItem value="option1">
  <RadioGroupLabel>Option 1</RadioGroupLabel>
</RadioGroupItem>
<RadioGroupItem value="option2">
  <RadioGroupLabel>Option 2</RadioGroupLabel>
</RadioGroupItem>
<RadioGroupItem value="option3">
  <RadioGroupLabel>Option 3</RadioGroupLabel>
</RadioGroupItem>
</RadioGroup>

Sizes

<RadioGroup value={value} onValueChange={setValue} size="sm">
{/* Small radio buttons */}
</RadioGroup>
 
<RadioGroup value={value} onValueChange={setValue} size="md">
{/* Medium (default) */}
</RadioGroup>
 
<RadioGroup value={value} onValueChange={setValue} size="lg">
{/* Large radio buttons */}
</RadioGroup>

Orientation

// Vertical (default)
<RadioGroup orientation="vertical" value={value} onValueChange={setValue}>
{/* Items stacked vertically */}
</RadioGroup>
 
// Horizontal
<RadioGroup orientation="horizontal" value={value} onValueChange={setValue}>
{/* Items in a row */}
</RadioGroup>

With Description

<RadioGroup value={value} onValueChange={setValue}>
<RadioGroupItem value="free">
  <View>
    <RadioGroupLabel>Free Plan</RadioGroupLabel>
    <RadioGroupDescription>
      Basic features for personal use
    </RadioGroupDescription>
  </View>
</RadioGroupItem>
 
<RadioGroupItem value="pro">
  <View>
    <RadioGroupLabel>Pro Plan</RadioGroupLabel>
    <RadioGroupDescription>
      Advanced features for professionals
    </RadioGroupDescription>
  </View>
</RadioGroupItem>
</RadioGroup>

Disabled State

// Disable entire group
<RadioGroup value={value} onValueChange={setValue} disabled>
{/* All items disabled */}
</RadioGroup>
 
// Disable specific item
<RadioGroup value={value} onValueChange={setValue}>
<RadioGroupItem value="option1">
  <RadioGroupLabel>Available</RadioGroupLabel>
</RadioGroupItem>
<RadioGroupItem value="option2" disabled>
  <RadioGroupLabel>Unavailable</RadioGroupLabel>
</RadioGroupItem>
</RadioGroup>

API Reference

Radio

Standalone radio button.

PropTypeDefaultDescription
checkedbooleanfalseWhether checked
onCheckedChange(checked: boolean) => voidChange callback
size'sm' | 'md' | 'lg''md'Radio size
disabledbooleanfalseDisable the radio
valuestringValue identifier
childrenReactNodeLabel content
classNamestringAdditional classes

RadioGroup

Group container for radio items.

PropTypeDefaultDescription
valuestringSelected value
onValueChange(value: string) => voidChange callback
orientation'vertical' | 'horizontal''vertical'Layout direction
size'sm' | 'md' | 'lg''md'Size for all items
disabledbooleanfalseDisable all items
childrenReactNodeRequiredRadioGroupItem children
classNamestringAdditional classes

RadioGroupItem

Individual radio option.

PropTypeDefaultDescription
valuestringRequiredOption value
disabledbooleanfalseDisable this item
childrenReactNodeLabel content
classNamestringAdditional classes

RadioGroupLabel

Label text for a radio item.

PropTypeDefaultDescription
childrenReactNodeRequiredLabel text
classNamestringAdditional classes

RadioGroupDescription

Description text for a radio item.

PropTypeDefaultDescription
childrenReactNodeRequiredDescription text
classNamestringAdditional classes

On this page