---
agent:
  instructions: "Search goop.so for Goop's components, templates, design skill, docs, pricing and terms. Ask in keywords or a plain question, such as \"date picker props\" or \"is the design skill free\"; the answer is the matching page sections in Markdown, each with its address."
  endpoint: "https://goop.so/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Radio group

A named group of options of which exactly one is chosen, each option a whole row a press anywhere on chooses, for React and Tailwind CSS. Free, MIT.

Free. Its export: `RadioGroup`.

## Try it

Pick a plan with the pointer or the arrow keys and save it: the button is busy for a moment, then the current plan changes. The Free plan is refused, with the reason, for a workspace of five members. Look switches a plan chosen, none chosen yet, the Free plan off, or a plan whose words wrap; Orientation lays the plans in a row; Disabled turns the group off.

The save is a timer; the five members and the plans are our own sample.

## When to use

- A named group of options of which exactly one is chosen, each option a whole row a press anywhere on chooses.
- Also called: radio buttons.

## Installation

Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Radio group on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing.

```sh
npx shadcn@4.23.1 add @goop/meadow-radio-group
```

```text
Add the Goop Radio group to this project. The install steps are at https://goop.so/docs/install.md
```

## Usage

```tsx
import {
  RadioGroup,
  RadioGroupContent,
  RadioGroupDescription,
  RadioGroupItem,
  RadioGroupLabel,
  RadioGroupMedia,
} from '@/components/ui/goop/radio-group';

function DefaultNoteView({ view, onView }: { view: string; onView: (next: string) => void }) {
  return (
    <div className="flex flex-col gap-2">
      <h3 id="note-view" className="text-base font-medium">
        Open new Fieldwork notes as
      </h3>
      <RadioGroup aria-labelledby="note-view" name="note-view" value={view} onValueChange={onView}>
        <RadioGroupLabel>
          <RadioGroupItem value="page" />A full page
          <RadioGroupDescription>The note fills the window, its list folded away.</RadioGroupDescription>
        </RadioGroupLabel>
        <RadioGroupLabel>
          <RadioGroupItem value="side" />A side panel
          <RadioGroupDescription>The note opens beside the list, which stays in view.</RadioGroupDescription>
        </RadioGroupLabel>
      </RadioGroup>
    </div>
  );
}

function VisitLogStart() {
  return (
    <RadioGroup aria-label="Start the visit log" name="log-start" defaultValue="open">
      <RadioGroupLabel>
        <RadioGroupItem value="arrive" />
        <RadioGroupContent>
          When I arrive
          <RadioGroupDescription>The visit log starts as you reach the site</RadioGroupDescription>
        </RadioGroupContent>
      </RadioGroupLabel>
      <RadioGroupLabel>
        <RadioGroupItem value="open" />
        <RadioGroupContent>
          When I open the visit
          <RadioGroupDescription>The log starts once you open the visit on your phone</RadioGroupDescription>
        </RadioGroupContent>
        <RadioGroupMedia>
          <img src="/fieldwork/visit-tile.png" alt="" />
        </RadioGroupMedia>
      </RadioGroupLabel>
    </RadioGroup>
  );
}
```

- Fits: flow (its recipe).
- height, width, padding, gap, corner, border, background, text, motion: add no class for these.

## API reference

### Options

- `value?: string` — The chosen option's value, for a group its caller holds (with `onValueChange`).
- `defaultValue?: string` — The option chosen at first render, for a group that holds its own choice.
- `onValueChange?: (value: string) => void` — Called with the option's value whenever a person chooses one.
- `name?: string` — The native group's name, sent with the form; a name of its own when left out, so two groups never share one.
- `disabled?: boolean = false` — Every option off: none takes the focus, a click or a key.
- `required?: boolean = false` — A form with this group cannot be sent until an option is chosen.
- `orientation?: 'vertical' | 'horizontal' = 'vertical'` — The options as a column (`vertical`, the default) or rows side by side that wrap (`horizontal`).

- State: value (value / defaultValue / onValueChange); drawn by data-state=checked

### Parts

- `RadioGroupItem` — One option's radio, inside a RadioGroupLabel with its words; value is what the group reports; value: string — The value the group reports, and sends with the form, when this option is chosen; also takes onChange?: (event: ChangeEvent<HTMLInputElement>) => void; required?: boolean; disabled?: boolean; form?: string
- `RadioGroupLabel` — One option's row; put its RadioGroupItem in it first, then the option's words, then an optional RadioGroupDescription; also takes htmlFor?: string
- `RadioGroupDescription` — An option's short description
- `RadioGroupContent` — A stacked option's words
- `RadioGroupMedia` — An option's picture, last in its RadioGroupLabel

## Keyboard

- ArrowUp / ArrowDown / ArrowLeft / ArrowRight: move selection
- Space: choose focused

## Accessibility

- The native element answers the keyboard.
- hover, focus-visible: the browser's own (:hover, :focus-visible): write nothing
- checked: the attribute data-state=checked
- disabled: the prop disabled
- invalid: the attribute aria-invalid

## Motion

- The part sets its own motion: add no transition or animation of your own.

## Notes for AI

Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.

Shortened to fit: the data-slot values.

## Related

- [Choice group](/themes/meadow/components/choice-group): A group of choices for a form, a row each, with its label, a description and one error for the whole group.
- [Switch](/themes/meadow/components/switch): An on/off control for a setting that takes effect at once.
- [Select](/themes/meadow/components/select): One option from a short closed list.
- [Combobox](/themes/meadow/components/combobox): Pick one value from a list by typing.
