---
layout: ~/layouts/MdxDocLayout.astro
title: "Radio"
description: "A control that allows the user to select one option from a set. Always used within a Radio.Group."
sourceFile: "components/radio"
baseUIComponent: "radio-group"
---

import ComponentExample from "~/components/docs/ComponentExample.astro";
import ComponentSection from "~/components/docs/ComponentSection.astro";
import Heading from "~/components/docs/Heading.astro";
import PropsTable from "~/components/docs/PropsTable.astro";
import {
  RadioBasicDemo,
  RadioDefaultDemo,
  RadioHorizontalDemo,
  RadioDescriptionDemo,
  RadioErrorDemo,
  RadioDisabledDemo,
  RadioControlPositionDemo,
  RadioCardDemo,
  RadioCardHorizontalDemo,
} from "~/components/demos/RadioDemo";

{/* Hero Demo */}

<ComponentSection>
  <ComponentExample demo="RadioBasicDemo">
    <RadioBasicDemo client:visible />
  </ComponentExample>
</ComponentSection>

{/* Installation */}

<ComponentSection>
  <Heading level={2}>Installation</Heading>
  <Heading level={3}>Barrel</Heading>

```tsx
import { Radio } from "@cloudflare/kumo";
```

<Heading level={3}>Granular</Heading>

```tsx
import { Radio } from "@cloudflare/kumo/components/radio";
```

</ComponentSection>

{/* Usage */}

<ComponentSection>
  <Heading level={2}>Usage</Heading>

```tsx
import { Radio } from "@cloudflare/kumo";

export default function Example() {
  return (
    <Radio.Group legend="Choose an option" defaultValue="a">
      <Radio.Item label="Option A" value="a" />
      <Radio.Item label="Option B" value="b" />
    </Radio.Group>
  );
}
```

</ComponentSection>

{/* Examples */}

<ComponentSection>
  <Heading level={2}>Examples</Heading>

<Heading level={3}>Default (Vertical)</Heading>
<p>
  Radio groups display vertically by default. Each radio has a label displayed
  to its right.
</p>
<ComponentExample demo="RadioDefaultDemo">
  <RadioDefaultDemo client:visible />
</ComponentExample>

<Heading level={3}>Horizontal</Heading>
<p>
  Use `orientation="horizontal"` for inline layouts. Items wrap when there isn't
  enough space.
</p>
<ComponentExample demo="RadioHorizontalDemo">
  <RadioHorizontalDemo client:visible />
</ComponentExample>

<Heading level={3}>With Description</Heading>
<p>Add helper text below the radio items using the `description` prop.</p>
<ComponentExample demo="RadioDescriptionDemo">
  <RadioDescriptionDemo client:visible />
</ComponentExample>

<Heading level={3}>Control Position</Heading>
<p>Use `controlPosition="end"` to place labels before radio buttons.</p>
<ComponentExample demo="RadioControlPositionDemo">
  <RadioControlPositionDemo client:visible />
</ComponentExample>

<Heading level={3}>Radio Card</Heading>
<p>
  Use `appearance="card"` on the group to display each option as a selectable
  card. Combine with the `description` prop on each item for richer content.
</p>
<ComponentExample demo="RadioCardDemo">
  <RadioCardDemo client:visible />
</ComponentExample>

<Heading level={3}>Radio Card (Horizontal)</Heading>
<p>
  Combine `appearance="card"` with `orientation="horizontal"` for a side-by-side
  card layout.
</p>
<ComponentExample demo="RadioCardHorizontalDemo">
  <RadioCardHorizontalDemo client:visible />
</ComponentExample>

<Heading level={3}>With Error</Heading>
<p>Show validation errors at the group level using the `error` prop.</p>
<ComponentExample demo="RadioErrorDemo">
  <RadioErrorDemo client:visible />
</ComponentExample>

<Heading level={3}>Disabled</Heading>
<p>Disable the entire group or individual items.</p>
<ComponentExample demo="RadioDisabledDemo">
  <RadioDisabledDemo client:visible />
</ComponentExample>

</ComponentSection>

{/* API Reference */}

<ComponentSection>
  <Heading level={2}>API Reference</Heading>

<Heading level={3}>Radio.Group</Heading>
<p>Container for radio buttons with legend, description, and error support.</p>
<PropsTable component="Radio.Group" />

<Heading level={3}>Radio.Item</Heading>
<p>Individual radio button within Radio.Group.</p>
<PropsTable component="Radio.Item" />

</ComponentSection>

{/* Accessibility */}

<ComponentSection>
  <Heading level={2}>Accessibility</Heading>
  <div class="space-y-4 text-sm">
    <div>
      <h3 class="mb-2 font-semibold">Semantic HTML</h3>
      <p class="text-kumo-strong">
        Radio.Group uses semantic `<fieldset>` and `<legend>` elements for proper grouping and screen reader announcement.
      </p>
    </div>
    <div>
      <h3 class="mb-2 font-semibold">Keyboard Navigation</h3>
      <p class="text-kumo-strong">
        <kbd class="rounded bg-kumo-control px-1.5 py-0.5">Arrow Up/Down</kbd> or <kbd class="rounded bg-kumo-control px-1.5 py-0.5">Arrow Left/Right</kbd> moves between options. <kbd class="rounded bg-kumo-control px-1.5 py-0.5">Space</kbd> selects the focused option. <kbd class="rounded bg-kumo-control px-1.5 py-0.5">Tab</kbd> moves focus to and from the radio group.
      </p>
    </div>
    <div>
      <h3 class="mb-2 font-semibold">Screen Readers</h3>
      <p class="text-kumo-strong">
        Each radio is announced with its label and selection state. The group legend provides context for all options.
      </p>
    </div>
  </div>
</ComponentSection>
