# u-radio

```ts
import '@iyulab/components/dist/components/radio/URadio.js';
import '@iyulab/components/dist/components/option/UOption.js';
```

**Tag:** `u-radio`

Radio group built from `u-option` children. Form-associated.

```html
<u-radio name="size" value="md">
  <u-option value="sm">Small</u-option>
  <u-option value="md">Medium</u-option>
  <u-option value="lg">Large</u-option>
</u-radio>

<!-- Button style, horizontal -->
<u-radio name="plan" type="button" orientation="horizontal" appearance="outlined">
  <u-option value="free">Free</u-option>
  <u-option value="pro">Pro</u-option>
  <u-option value="enterprise">Enterprise</u-option>
</u-radio>

<!-- Segmented control -->
<u-radio name="view" type="button" orientation="horizontal" appearance="soft" value="list">
  <u-option value="list">List</u-option>
  <u-option value="board">Board</u-option>
</u-radio>
```

---

## Slots

| Name | Description |
|------|-------------|
| *(default)* | `u-option` elements |

## Properties

| Property | Type | Default | Reflect | Description |
|----------|------|---------|---------|-------------|
| `value` | `string` | — | — | Currently selected value |
| `type` | `'default'\|'button'` | `'default'` | ✓ | `button` renders options as toggle buttons |
| `appearance` | `'solid'\|'outlined'\|'soft'` | `'solid'` | ✓ | `solid` fills the picked option · `outlined` · `soft` (`type="button"` only) a segmented control — a quiet track where the picked segment rises onto the surface |
| `orientation` | `'vertical'\|'horizontal'` | `'vertical'` | ✓ | Layout direction |
| `disabled` | `boolean` | `false` | ✓ | Disable all options |
| `readonly` | `boolean` | `false` | ✓ | Read-only |
| `required` | `boolean` | `false` | ✓ | Required |
| `invalid` | `boolean` | `false` | ✓ | Validation failed |
| `name` | `string` | — | — | Form field name |

## Events

| Event | Description |
|-------|-------------|
| `change` | Fires when the user changes the selection — click, Space/Enter, or an arrow key |

## Methods

| Method | Description |
|--------|-------------|
| `validate()` | Validate; sets `invalid` |
| `reset()` | Reset selection |
| `focus(options?)` | Focus the group's tab stop — the selected option, or the first enabled one |
| `blur()` | Blur the currently focused option, if any |

## Keyboard

The group is one tab stop (the selected option, or the first enabled one). Arrow keys move focus
**and** selection together, wrapping at the ends; Home/End jump to the first/last option — the
native radio group and WAI-ARIA APG behaviour.

## CSS Parts

| Part | Description |
|------|-------------|
| `field` | Outer field wrapper |
| `container` | Options container |

## CSS Custom Properties

| Property | Description |
|----------|-------------|
| `--radio-color` | Base color of the selected state (default `--u-selection-color`, which is `--u-primary-color` unless the theme sets it) |
| `--radio-color-active` | Selected-state active tone (default `--radio-color` at 85% + black) |
