---
name: "radio-group"
mode: "component"
versionRequirements:
  - { name: "Base Library", version: "2.10.0" }
title: "radio-group - Single-select picker composed of multiple radio items"
---

## radio-group

> [VERSION] Base Library >= 2.10.0

### Description

Single-choice group composed of multiple radio components.

### Props

| Property | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `name` | `string` | No | - | Field name in the form |

#### Events

| Event | Type | Description |
| --- | --- | --- |
| `change` | `(event: RadioGroupChangeEvent) => void` | Fires when the selected item changes |

**RadioGroupChangeEvent**

| Field | Type | Description |
| --- | --- | --- |
| `type` | `"change"` | Event type |
| `detail` | `RadioGroupChangeDetail` | Event data |

### Examples

#### Basic usage

*index.tyml*

```xml
<radio-group bind:change="onChange">
  <label ty:for="{{items}}" ty:key="{{item.value}}" class="item">
    <radio value="{{item.value}}" />
    <text>{{item.name}}</text>
  </label>
</radio-group>
<text class="result">Selected:{{selected}}</text>
```

*index.tyss*

```css
.item {
  display: flex;
  align-items: center;
  margin-bottom: 10rpx;
}
.result {
  margin-top: 20rpx;
}
```

*index.js*

```javascript
Page({
  data: {
    items: [
      { value: 'apple', name: 'Apple' },
      { value: 'banana', name: 'Banana' },
      { value: 'grape', name: 'Grape' },
    ],
    selected: '',
  },
  onChange(e) {
    this.setData({ selected: e.detail.value });
  },
});
```
