# RadioGroup

> A set of mutually exclusive options, built on real input type=radio elements sharing one name so the browser gives the roving tab stop and keyboard navigation for free.

- Package: `fancy-ui-vue` (Vue 3.5+ + Tailwind CSS v4)
- Category: Forms
- Tags: radio, form, selection, compound, validation
- Types: `RadioGroupProps`, `RadioGroupOrientation`, `RadioGroupItemProps`, `RadioGroupContext`
- Docs: https://fancy-ui.rama.app/docs/components/radio-group
- Source: https://github.com/RamaHerbin/fancy-ui/tree/main/vue/src/components/radio-group

## Import

```vue
<script setup lang="ts">
import { RadioGroup } from 'fancy-ui-vue';
</script>
```

Setup (once per project): `npm install fancy-ui-vue`, then put these lines in your main CSS file (the stylesheet imports go right after `@import "tailwindcss";`):

```css
@import "tailwindcss";
@import "fancy-ui-vue/tailwind.css";
@import "fancy-ui-vue/styles.css";
```

Full guide: https://fancy-ui.rama.app/llms.txt

The names below are the ones to write in a Vue template; when one differs from the Svelte name, the Svelte name follows in parentheses. Snippets become named slots (`#default` is the default snippet), a prop the Vue port declares as a model is a `v-model:<name>` (except `ref`, exposed via `defineExpose({ ref })`: put a template ref on the component and read `.ref`) and callbacks are listeners (`onclick` is `@click`). Every component sets `inheritAttrs: false`: `class` is a declared prop, merged where the Svelte component applies it (not always the root element), and only when the props table below lists it; other attributes do not fall through unless the package README lists the component as forwarding native attributes. Divergences: https://github.com/RamaHerbin/fancy-ui/tree/main/vue#divergences-from-the-svelte-api

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `v-model:value` (Svelte `value`) | `string` | `""` | The selected value, bindable — "" means nothing is selected. |
| `@value-change` (Svelte `onValueChange`) | `(value: string) => void` | — | Called with the new value whenever the selection changes. |
| `name` | `string` | — | Shared name for the native radios. Generated per instance when omitted, so two groups on the same page never fight over each other's selection. |
| `disabled` | `boolean` | `false` | Disables every item in the group. |
| `required` | `boolean` | `false` | Marks the group required for native form validation. |
| `invalid` | `boolean` | `false` | Marks the group invalid — sets aria-invalid. |
| `orientation` | `"horizontal" \| "vertical"` | `"vertical"` | The list's stacking axis. |
| `label` | `string` | — | Accessible name, standalone. Inside a FormField that rendered its own label, its labelId wins instead; a FormField with no label of its own falls back to this. |
| `class` | `string` | — | Additional CSS classes, merged onto the root. |
| `ref` | `HTMLDivElement \| null` | `null` | Bindable reference to the root element. |
| `RadioGroupItem.value` (required) | `string` | — | This item's value — what the group's value becomes when it is picked. |
| `RadioGroupItem.disabled` | `boolean` | `false` | Disables just this item, independent of the group's own disabled. |
| `RadioGroupItem.label` | `string` | — | Visible label text. Also the fallback content, and the fallback name. |
| `RadioGroupItem.class` | `string` | — | Additional CSS classes, merged onto the wrapping label. |
| `RadioGroupItem.ref` | `HTMLInputElement \| null` | `null` | Bindable reference to the item's native input. |
| `sound` | `boolean` | `false` | Plays a select cue when the selection actually changes, once the user has enabled sound |

## Slots

| Slot | Description |
| --- | --- |
| `#default` (Svelte `children`) | The RadioGroup's content — the RadioGroupItems. |
| `RadioGroupItem.#default` (Svelte `RadioGroupItem.children`) | Custom content rendered in place of the item's label. |

## Example

```vue
<script setup lang="ts">
import { ref } from "vue";
import { RadioGroup, RadioGroupItem } from "fancy-ui-vue";

const plan = ref("starter");
</script>

<template>
	<RadioGroup v-model:value="plan" sound label="Plan">
		<RadioGroupItem value="starter" label="Starter" />
		<RadioGroupItem value="team" label="Team" />
		<RadioGroupItem value="enterprise" label="Enterprise" />
	</RadioGroup>
</template>
```
