Radio Group

A group of radio buttons for single selection

A radio group component built with Ark UI. Use the convenience API with options and optional label, or the compound API for custom layout.

import { RadioGroup } from "@/components/ui/radio-group";

const options = [
  { value: "react", label: "React" },
  { value: "vue", label: "Vue" },
  { value: "svelte", label: "Svelte" },
];

export default function Example() {
  return (
    <RadioGroup
      label="Framework"
      options={options}
      defaultValue="react"
    />
  );
}

Installation

bash
liminal add radio-group

Usage

Pass options (array of { value, label, disabled? }), optional label, and defaultValue or controlled value and onValueChange.

<RadioGroup
  options={[
    { value: "a", label: "Option A" },
    { value: "b", label: "Option B" },
  ]}
  defaultValue="a"
/>

Examples

With label and disabled option

<RadioGroup
  label="Choose one"
  options={[
    { value: "yes", label: "Yes" },
    { value: "no", label: "No" },
    { value: "maybe", label: "Maybe", disabled: true },
  ]}
  defaultValue="yes"
/>

Compound API

Use RadioGroupRoot, RadioGroupLabel, RadioGroupItem, RadioGroupItemText, RadioGroupItemControl, and RadioGroupItemHiddenInput for full control.

tsx
import {
  RadioGroupRoot,
  RadioGroupLabel,
  RadioGroupItem,
  RadioGroupItemText,
  RadioGroupItemControl,
  RadioGroupItemHiddenInput,
} from "@/components/ui/radio-group";

export default function Example() {
  return (
    <RadioGroupRoot defaultValue="react">
      <RadioGroupLabel>Framework</RadioGroupLabel>
      <RadioGroupItem value="react">
        <RadioGroupItemHiddenInput />
        <RadioGroupItemControl />
        <RadioGroupItemText>React</RadioGroupItemText>
      </RadioGroupItem>
      <RadioGroupItem value="vue">
        <RadioGroupItemHiddenInput />
        <RadioGroupItemControl />
        <RadioGroupItemText>Vue</RadioGroupItemText>
      </RadioGroupItem>
    </RadioGroupRoot>
  );
}

API

PropTypeDefaultDescription
options{ value: string; label: React.ReactNode; disabled?: boolean }[]-Radio options (convenience API).
labelReact.ReactNode-Group label (convenience API).
defaultValuestring-Initial selected value.
valuestring-Controlled selected value.
onValueChange(details: { value: string }) => void-Callback when selection changes.