# Radio List

## Usage

`RadioList` picks one value. Put a `RadioListItem` in the default slot, or pass an `options` array when the rows are plain text.

```vue
<script setup lang="ts">
import { RadioList, RadioListItem } from '@astryx-vue/core/RadioList'
import { shallowRef } from 'vue'

const channel = shallowRef('')
</script>

<template>
  <RadioList v-model="channel" label="Notification preference">
    <RadioListItem label="Email" value="email" />
    <RadioListItem label="SMS" value="sms" />
  </RadioList>
</template>
```

The indicator is 24px by default, and 20px when `size="sm"`. `orientation="horizontal"` lays the rows in a row with a 20px gap. The `end` slot sits on the trailing edge.

### Anatomy

- **Header**: Optional heading above the radio list.
- **Children**: The radio list items rendered as selectable options.
- **Label/Value**: The text label and associated value for each radio item.

## Best practices

| Guideline | Practice |
| --- | --- |
| Do | Keep the list short, usually two to seven options. |
| Don't | Use it when more than one option can be selected. Use CheckboxList. |
| Don't | Use a horizontal list for more than about four options. |

## Examples

### Horizontal

Small, medium, and large in a row.

```vue
<script setup lang="ts">
import { RadioList, RadioListItem } from '@astryx-vue/core/RadioList'
import { shallowRef } from 'vue'

const value = shallowRef('md')
</script>

<template>
  <RadioList v-model="value" label="Size" orientation="horizontal">
    <RadioListItem label="Small" value="sm" />
    <RadioListItem label="Medium" value="md" />
    <RadioListItem label="Large" value="lg" />
  </RadioList>
</template>
```
### Pricing tier

Each plan shows its price at the end of the row.

```vue
<script setup lang="ts">
import { RadioList, RadioListItem } from '@astryx-vue/core/RadioList'
import { Text } from '@astryx-vue/core/Text'
import { shallowRef } from 'vue'

const value = shallowRef('')
</script>

<template>
  <RadioList v-model="value" label="Plan">
    <RadioListItem label="Free" value="free">
      <template #end>
        <Text type="body" color="secondary">
          $0/mo
        </Text>
      </template>
    </RadioListItem>
    <RadioListItem label="Pro" value="pro">
      <template #end>
        <Text type="body" color="secondary">
          $9/mo
        </Text>
      </template>
    </RadioListItem>
    <RadioListItem label="Enterprise" value="enterprise">
      <template #end>
        <Text type="body" color="secondary">
          Custom
        </Text>
      </template>
    </RadioListItem>
  </RadioList>
</template>
```
### With descriptions

A description under each option.

```vue
<script setup lang="ts">
import { RadioList, RadioListItem } from '@astryx-vue/core/RadioList'
import { shallowRef } from 'vue'

const value = shallowRef('')
</script>

<template>
  <RadioList v-model="value" label="Notification preference" description="Choose how you would like to be notified">
    <RadioListItem label="Email" value="email" description="Receive notifications via email" />
    <RadioListItem label="SMS" value="sms" description="Standard messaging rates apply" />
    <RadioListItem label="Push notification" value="push" description="Instant alerts on your device" />
  </RadioList>
</template>
```
### With validation

An empty required group shows an error.

```vue
<script setup lang="ts">
import { RadioList, RadioListItem } from '@astryx-vue/core/RadioList'
import { computed, shallowRef } from 'vue'

const value = shallowRef('')
const status = computed(() => value.value === ''
  ? { type: 'error' as const, message: 'Please select a notification method' }
  : undefined)
</script>

<template>
  <RadioList v-model="value" label="Notification preference" is-required :status="status">
    <RadioListItem label="Email" value="email" />
    <RadioListItem label="SMS" value="sms" />
    <RadioListItem label="Push notification" value="push" />
  </RadioList>
</template>
```

## RadioList Props

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `v-model` | `string \| number` | — | Required. The selected value. |
| `label` | `string` | — | Required accessible name of the group. |
| `options` | `RadioOption[]` | — | Plain options. Use items when a row needs an end slot. |
| `orientation` | `'vertical' \| 'horizontal'` | `'vertical'` | Stack the rows, or place them in a row. |
| `size` | `'sm' \| 'md'` | `'md'` | Indicator size. 20px or 24px. A plain Radio stays 18px. |
| `description` | `string` | — | Help text under the group label. |
| `status` | `FieldStatusInput` | — | Error, warning, or success. |
| `statusVariant` | `'attached' \| 'detached' \| 'tooltip'` | `'detached'` | Where the status message sits. |
| `isDisabled` | `boolean` | `false` | Disables the group. |
| `disabledMessage` | `string` | — | Why the whole group is disabled. With `isDisabled`, the message shows in a tooltip on hover or keyboard focus and every option stays focusable with `aria-disabled`; selection stays blocked. |
| `isRequired` | `boolean` | `false` | Marks the group required. |
| `containerClass` | `string` | — | Class on the field shell. It has no effect inside a horizontal-labels form. |
| `containerStyle` | `StyleValue` | — | Inline style on the field shell. |
| `controlClass` | `string` | — | Class on the radio group (`role="radiogroup"`). |
| `controlStyle` | `StyleValue` | — | Inline style on the radio group. |

## RadioListItem Props

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `value` | `string \| number` | — | Required value submitted when the row is selected. |
| `label` | `string` | — | Required row label. Use the `label` slot for rich content such as a link; activating the link does not select the row. |
| `description` | `string` | — | Secondary text under the label. Rich content goes in the `description` slot. |
| `isDisabled` | `boolean` | `false` | Disables this row. |

The `end` slot renders after the label, aligned to the trailing edge in a vertical list.

## Accessibility

### Radio circle

- Criterion: 1.4.11 Non-text Contrast
- Check: 3:1
- States: Rest, Hover, Pointer down, Selected

The circle edge (unselected) and fill (selected) must have at least 3:1 contrast with the surface behind them. For Hover and Pointer down, measure the final colors after the tint and the pressed overlay are applied.
