2021-10-22 19:32:39 +08:00
---
2021-10-25 15:21:08 +08:00
title: Radio
2021-10-22 19:32:39 +08:00
lang: en-US
---
# Radio
2021-09-17 00:18:50 +08:00
Single selection among multiple options.
2021-11-10 09:38:05 +08:00
## Basic usage
2021-09-17 00:18:50 +08:00
Radio should not have too many options. Otherwise, use the Select component instead.
:::demo Creating a radio component is easy, you just need to bind a variable to Radio's `v-model` . It equals to the value of `label` of the chosen radio. The type of `label` is `String` , `Number` or `Boolean` .
radio/basic-usage
:::
2021-11-10 09:38:05 +08:00
## Disabled
2021-09-17 00:18:50 +08:00
`disabled` attribute is used to disable the radio.
:::demo You just need to add the `disabled` attribute.
radio/disabled
:::
2021-11-10 09:38:05 +08:00
## Radio button group
2021-09-17 00:18:50 +08:00
Suitable for choosing from some mutually exclusive options.
:::demo Combine `el-radio-group` with `el-radio` to display a radio group. Bind a variable with `v-model` of `el-radio-group` element and set label value in `el-radio` . It also provides `change` event with the current value as its parameter.
radio/radio-button-group
:::
2021-11-10 09:38:05 +08:00
## Button style
2021-09-17 00:18:50 +08:00
Radio with button styles.
:::demo You just need to change `el-radio` element into `el-radio-button` element. We also provide `size` attribute.
radio/button-style
:::
2021-11-10 09:38:05 +08:00
## With borders
2021-09-17 00:18:50 +08:00
:::demo The `border` attribute adds a border to Radios.
radio/with-borders
:::
2023-01-12 18:56:16 +08:00
## Radio API
2021-09-17 00:18:50 +08:00
2023-01-12 18:56:16 +08:00
### Radio Attributes
2021-09-17 00:18:50 +08:00
2023-01-12 18:56:16 +08:00
| Name | Description | Type | Default |
| --------------------- | ------------------------------------ | ---------------------------------------- | ------- |
| model-value / v-model | binding value | ^[string] / ^[number] / ^[boolean] | — |
2023-01-31 18:16:06 +08:00
| label | the value of Radio | ^[string] / ^[number] / ^[boolean] | — |
| disabled | whether Radio is disabled | ^[boolean] | false |
| border | whether to add a border around Radio | ^[boolean] | false |
| size | size of the Radio | ^[enum]`'large' \| 'default' \| 'small'` | — |
2023-01-12 18:56:16 +08:00
| name | native `name` attribute | ^[string] | — |
2021-09-17 00:18:50 +08:00
2023-01-12 18:56:16 +08:00
### Radio Events
2021-09-17 00:18:50 +08:00
2023-01-12 18:56:16 +08:00
| Name | Description | Type |
| ------ | ------------------------------------- | --------------------------------------------------------- |
| change | triggers when the bound value changes | ^[Function]`(value: string \| number \| boolean) => void` |
2021-10-04 08:26:51 +08:00
2023-01-12 18:56:16 +08:00
### Radio Slots
2021-10-04 08:26:51 +08:00
2023-01-12 18:56:16 +08:00
| Name | Description |
| ------- | ------------------------- |
| default | customize default content |
2021-09-17 00:18:50 +08:00
2023-01-12 18:56:16 +08:00
## RadioGroup API
2021-09-17 00:18:50 +08:00
2023-01-12 18:56:16 +08:00
### RadioGroup Attributes
2021-09-17 00:18:50 +08:00
2023-01-12 18:56:16 +08:00
| Name | Description | Type | Default |
| --------------------- | ------------------------------------------------- | ---------------------------------- | ------- |
| model-value / v-model | binding value | ^[string] / ^[number] / ^[boolean] | — |
| size | the size of radio buttons or bordered radios | ^[string] | default |
| disabled | whether the nesting radios are disabled | ^[boolean] | false |
| text-color | font color when button is active | ^[string] | #ffffff |
| fill | border and background color when button is active | ^[string] | #409EFF |
| validate-event | whether to trigger form validation | ^[boolean] | true |
2023-04-09 21:02:49 +08:00
| label ^(a11y) | same as `aria-label` in RadioGroup | ^[string] | — |
2023-01-12 18:56:16 +08:00
| name | native `name` attribute | ^[string] | — |
| id | native `id` attribute | ^[string] | — |
2021-09-17 00:18:50 +08:00
2023-01-12 18:56:16 +08:00
### RadioGroup Events
2021-10-04 08:26:51 +08:00
2023-01-12 18:56:16 +08:00
| Name | Description | Type |
| ------ | ------------------------------------- | --------------------------------------------------------- |
| change | triggers when the bound value changes | ^[Function]`(value: string \| number \| boolean) => void` |
2021-10-04 08:26:51 +08:00
2023-01-12 18:56:16 +08:00
### RadioGroup Slots
2021-09-17 00:18:50 +08:00
2023-01-12 18:56:16 +08:00
| Name | Description | Subtags |
| ------- | ------------------------- | ------------------- |
| default | customize default content | Radio / RadioButton |
2021-10-04 08:26:51 +08:00
2023-01-12 18:56:16 +08:00
## RadioButton API
2021-10-04 08:26:51 +08:00
2023-01-12 18:56:16 +08:00
### RadioButton Attributes
| Name | Description | Type | Default |
| -------- | ------------------------- | ---------------------------------- | ------- |
2023-01-31 18:16:06 +08:00
| label | the value of Radio | ^[string] / ^[number] / ^[boolean] | — |
| disabled | whether Radio is disabled | ^[boolean] | false |
2023-01-12 18:56:16 +08:00
| name | native 'name' attribute | ^[string] | — |
### RadioButton Slots
| Name | Description |
| ------- | ------------------------- |
| default | customize default content |