# RadioGroup

A labeled set of options where only one can be picked.

- **Use it for**: One choice from a short list where every option should stay visible.
- **Not for**: More than about seven options. Try [Select](https://unseenui.com/components/select/), [ToggleGroup](https://unseenui.com/components/toggle-group/).

## Installation

```bash
npm install @stackunseen/ui
```

## Usage

```tsx
import { RadioGroup } from '@stackunseen/ui';
import { Field } from '@stackunseen/ui';
import '@stackunseen/ui/styles.css';

<Field label="Project visibility" labelAs="span"><RadioGroup value={visibility} onValueChange={setVisibility} options={[{value: "public", label: "Public"}, {value: "private", label: "Private"}]} /></Field>
```

## All props

| Prop | Type | Description |
| --- | --- | --- |
| `defaultValue` | `string` |  |
| `emptyMessage` | `ReactNode` |  |
| `form` | `string` | An external form owner, matching the native inputs' form attribute. |
| `label` | `ReactNode` | A visible group name, rendered as the fieldset's legend. |
| `onValueChange` | `((value: string) => void)` |  |
| `options` (required) | `readonly RadioGroupOption[]` |  |
| `orientation` | `"horizontal" \| "vertical"` |  |
| `required` | `boolean` |  |
| `value` | `string` |  |

## Keyboard

Tab enters the selected radio; arrow keys move and select within the native group. Space selects the focused option.

## Works with

[Field](https://unseenui.com/components/field/), [Input](https://unseenui.com/components/input/), [Textarea](https://unseenui.com/components/textarea/), [Checkbox](https://unseenui.com/components/checkbox/), [Switch](https://unseenui.com/components/switch/), [TonePad](https://unseenui.com/components/tone-pad/), [Slider](https://unseenui.com/components/slider/), [InputGroup](https://unseenui.com/components/input-group/), [Combobox](https://unseenui.com/components/combobox/), [Calendar](https://unseenui.com/components/calendar/), [DateRangePicker](https://unseenui.com/components/date-range-picker/), [Select](https://unseenui.com/components/select/)

Page: https://unseenui.com/components/radio-group/
