# Radio (/docs/native/components/radio)

<Preview id="radio/variants-and-states" title={null} />

## Installation [#installation]

<ComponentInstall name="radio" />

## Usage [#usage]

```tsx title="app/index.tsx"
import { Radio } from "@/components/ui/radio";
import { useState } from "react";
import { View } from "react-native";

export default function Example() {
  const [plan, setPlan] = useState<string | null>("monthly");

  return (
    <View className="flex-1 items-center justify-center p-4">
      <Radio.Group accessibilityLabel="Plan" selected={plan} onSelected={setPlan}>
        <Radio value="monthly">
          <Radio.Label>Monthly</Radio.Label>
        </Radio>
        <Radio value="annual">
          <Radio.Label>Annual</Radio.Label>
        </Radio>
      </Radio.Group>
    </View>
  );
}
```

## Variants [#variants]

`secondary` fills the ring; `primary` leaves it hollow.

<Preview id="radio/variants-and-states" />

```tsx
<Radio variant="primary" value="monthly">Monthly</Radio>
<Radio variant="secondary" value="annual">Annual</Radio>
```

## Sizes [#sizes]

<Preview id="radio/sizes" />

```tsx
<Radio size="sm" value="sm">Small</Radio>
<Radio size="md" value="md">Medium</Radio>
<Radio size="lg" value="lg">Large</Radio>
```

## Descriptions [#descriptions]

There is no `Radio.Description` — compose a `Text.Caption` inside the row and it stays within the
one tap target and inside the accessible name.

<Preview id="radio/per-option-description" />

```tsx
<Radio value="standard">
  <View className="min-w-0 shrink gap-0.5">
    <Radio.Label>Standard</Radio.Label>
    <Text.Caption>Arrives in three to five days.</Text.Caption>
  </View>
</Radio>
```

## Trailing indicator [#trailing-indicator]

Write a `Radio.Indicator` last and the row spreads to push the ring to the far edge.

<Preview id="radio/custom-indicator" />

```tsx
<Radio value="standard">
  <View className="min-w-0 shrink gap-0.5">
    <Radio.Label>Standard delivery</Radio.Label>
    <Text.Caption>Arrives in three to five days.</Text.Caption>
  </View>
  <Radio.Indicator />
</Radio>
```

## Inside a field [#inside-a-field]

The group names no state of its own — `isInvalid` and `isDisabled` reach every ring from the
enclosing `Field`.

```tsx
<Field isInvalid={plan === undefined}>
  <Field.Label>Plan</Field.Label>
  <Radio.Group accessibilityLabel="Plan" onSelected={setPlan} selected={plan ?? null}>
    <Radio value="free">Free</Radio>
    <Radio value="pro">Pro</Radio>
  </Radio.Group>
  <Field.Error>Pick a plan to continue.</Field.Error>
</Field>
```

## Reading the radio's state [#reading-the-radios-state]

Use `useRadio()` to read the settled state from a custom child, and `useRadioGroup()` for the
group's own.

```tsx
import { useRadio, useRadioGroup } from "@delacour/react-native-ui/radio";
```

## API Reference [#api-reference]

### Anatomy [#anatomy]

| Part | What it is |
| --- | --- |
| `Radio` | One option. A `Pressable` that selects its `value` in the enclosing group |
| `Radio.Label` | The option's text, inside the tap target |
| `Radio.Indicator` | The dot. Accepts custom children to replace the default glyph |
| `Radio.Group` | Owns the selected value and the shared axes |

### Radio [#radio]

A radio is a `Pressable`, so `feedback`, `haptic` and the rest are inherited — see
[Pressable](/docs/native/components/pressable). The shared axes resolve
`group ?? own ?? field ?? default`.

<TypeTable
  type={{
    value: {
      type: "string",
      description: "Identifies this radio to an enclosing `Radio.Group`. Required inside one.",
    },
    isSelected: { type: "boolean", description: "Controlled. Ignored inside a group, which owns the selection." },
    defaultSelected: { type: "boolean" },
    onSelected: {
      type: "(isSelected: boolean) => void",
      description: "Only ever called with `true` — a radio does not deselect itself. Ignored inside a group.",
    },
    variant: { type: '"primary" | "secondary"', default: '"primary"' },
    size: { type: '"sm" | "md" | "lg"', default: '"md"' },
    isInvalid: { type: "boolean", description: "Read from an enclosing `Field` when unset." },
    isDisabled: { type: "boolean" },
    className: { type: "string" },
    children: { type: "ReactNode", description: "Bare strings are wrapped in a `Radio.Label` automatically." },
  }}
/>

### Radio.Group [#radiogroup]

Owns which radio is selected. Extends `ViewProps`.

<TypeTable
  type={{
    selected: { type: "string | null", description: "Controlled. `null` is a controlled empty, not an absence." },
    defaultSelected: { type: "string | null" },
    onSelected: { type: "(value: string) => void" },
    variant: { type: '"primary" | "secondary"' },
    size: { type: '"sm" | "md" | "lg"' },
    orientation: { type: '"vertical" | "horizontal"', default: '"vertical"' },
    isInvalid: { type: "boolean" },
    isDisabled: { type: "boolean", description: "Blocks every radio. A radio's own prop still overrides it." },
    className: { type: "string" },
  }}
/>

<Callout type="warn">
A group renders no legend, and React Native has no `aria-labelledby` to tie it to a `Field.Label`
above it — so pass `accessibilityLabel` or the group is announced without a name.
</Callout>

### Radio.Indicator [#radioindicator]

The dot. Composed in when a radio holds none of its own; write it out to restyle it or to replace
the glyph entirely.

<TypeTable
  type={{
    children: {
      type: "ReactNode | ((props: RadioIndicatorChildrenProps) => ReactNode)",
      description: "A render function receives `{ isSelected, isInvalid, size, variant }`.",
    },
    dotProps: { type: "Animated.ViewProps & { className?: string }", description: "Reaches the inner dot without replacing it." },
    className: { type: "string" },
  }}
/>

### Radio.Label [#radiolabel]

The radio's text, wired as its accessible name. Extends React Native's `TextProps`.

<TypeTable type={{ className: { type: "string" }, children: { type: "ReactNode" } }} />

### Exports [#exports]

```tsx
import {
  Radio,
  type RadioProps,
  RADIO_VARIANTS,
  RADIO_SIZES,
  RADIO_ORIENTATIONS,
  RADIO_DOT_SPRING,
  RADIO_DEFAULT_SIZE,
  RADIO_DEFAULT_VARIANT,
  RADIO_LABEL_TEXT_SIZE,
} from "@delacour/react-native-ui/radio";
```
