# Radio group

A set of choices where one can be picked. Arrow keys move between them. Leave `value` empty (or pass "") so nothing is chosen until the person chooses.

- Registry name: `radio-group` (`@candor/radio-group`)
- Tier: Pro. Installing it needs a Pro, Premium or Team licence key: the person runs `npx candor-ui key <key>` themselves; never ask for the key in chat or write it to a file.
- Docs: https://candor.themethodic.com/docs/radio-group

## Install

```bash
npx candor-ui add radio-group
```

Run `npx candor-ui@latest init` once first (https://candor.themethodic.com/get-started.md). Without the CLI: `npx shadcn@latest add @candor/radio-group`.
It brings in: render-prop, utils.
npm packages: lucide-react@^1.67.0, radix-ui@^1.8.1.

## Example

```tsx
"use client"

import * as React from "react"
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"

const choices = [
  { value: "approve", label: "Approve and send as written", detail: "The customer gets this reply with its sources." },
  { value: "edit", label: "Edit, then send", detail: "Counts as a fail, with your reason." },
  { value: "reject", label: "Reject: send nothing", detail: "Nothing reaches the customer." },
]

export default function Example() {
  // Nothing is chosen until the person chooses.
  const [decision, setDecision] = React.useState("")
  return (
    <RadioGroup aria-label="Your decision" value={decision} onValueChange={setDecision} className="w-full max-w-sm">
      {choices.map((c) => (
        <label key={c.value} className="flex cursor-pointer items-start gap-2.5 rounded-lg border px-3 py-2 text-sm has-[[data-state=checked]]:border-ring has-[[data-state=checked]]:bg-accent/60">
          <RadioGroupItem value={c.value} className="mt-0.5" />
          <span>
            <span className="font-medium">{c.label}</span>
            <span className="block text-xs text-muted-foreground">{c.detail}</span>
          </span>
        </label>
      ))}
    </RadioGroup>
  )
}
```

## <RadioGroup>

No props.

Also takes the props of `React.ComponentProps<typeof RadioGroupPrimitive.Root>`, `RenderProp`.

## <RadioGroupItem>

One choice. Pair it with a label: wrap both in a <label>, or give it an id and the label `htmlFor`.

No props.

Also takes the props of `React.ComponentProps<typeof RadioGroupPrimitive.Item>`, `RenderProp`.

## Rules for using Candor UI

- Components take plain typed data. Never pass model output as HTML or render it as a link; messages are typed blocks.
- A control that can't be used says why: wrap it in `<Locked reason="…">`, don't just disable it.
- Don't show a value you don't have: leave it out (it renders as —) rather than guess. An estimate is labelled as one.
- Nothing is pre-selected in a decision a person makes, and the agent is named from your app's data, never from model output.
- Your app's words go in `LocaleProvider` (fixed strings) and `TermsProvider` (nouns); entity kinds and agent roles in `EntityKindsProvider` and `AgentRolesProvider`.
