1e41f4b71Sopenharmony_ci# Radio Button (Radio)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci
4e41f4b71Sopenharmony_ciThe **Radio** component allows users to select from a set of mutually exclusive options. Only one radio button in a given group can be selected at the same time. For details, see [Radio](../reference/apis-arkui/arkui-ts/ts-basic-components-radio.md).
5e41f4b71Sopenharmony_ci
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ci## Creating a Radio Button
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ciYou can create a radio button by calling the following API:
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci```ts
13e41f4b71Sopenharmony_ciRadio(options: {value: string, group: string})
14e41f4b71Sopenharmony_ci```
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ciIn this API, **value** indicates the name of the radio button, and **group** indicates the name of the group to which the radio button belongs. You can use the **checked** attribute of the radio button to specify whether it is selected. The value **true** means that the radio button is selected.
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ciThe style of the radio button can be customized for the selected and unselected states, but the shape cannot be customized.
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_ci```ts
21e41f4b71Sopenharmony_ciRadio({ value: 'Radio1', group: 'radioGroup' })
22e41f4b71Sopenharmony_ci  .checked(false)
23e41f4b71Sopenharmony_ciRadio({ value: 'Radio2', group: 'radioGroup' })
24e41f4b71Sopenharmony_ci  .checked(true)
25e41f4b71Sopenharmony_ci```
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ci![en-us_image_0000001562820821](figures/en-us_image_0000001562820821.png)
29e41f4b71Sopenharmony_ci
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ci## Adding Events
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ciThe **Radio** component supports the [universal events](../reference/apis-arkui/arkui-ts/ts-universal-events-click.md). In addition, it can be bound to the **onChange** event so that it responds with custom behavior after being selected.
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ci```ts
36e41f4b71Sopenharmony_ci  Radio({ value: 'Radio1', group: 'radioGroup' })
37e41f4b71Sopenharmony_ci    .onChange((isChecked: boolean) => {
38e41f4b71Sopenharmony_ci      if(isChecked) {
39e41f4b71Sopenharmony_ci        // Operation
40e41f4b71Sopenharmony_ci      }
41e41f4b71Sopenharmony_ci    })
42e41f4b71Sopenharmony_ci  Radio({ value: 'Radio2', group: 'radioGroup' })
43e41f4b71Sopenharmony_ci    .onChange((isChecked: boolean) => {
44e41f4b71Sopenharmony_ci      if(isChecked) {
45e41f4b71Sopenharmony_ci        // Operation
46e41f4b71Sopenharmony_ci      }
47e41f4b71Sopenharmony_ci    })
48e41f4b71Sopenharmony_ci```
49e41f4b71Sopenharmony_ci
50e41f4b71Sopenharmony_ci
51e41f4b71Sopenharmony_ci## Example Scenario
52e41f4b71Sopenharmony_ci
53e41f4b71Sopenharmony_ciIn this example, the **Radio** components are used to switch between sound modes.
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_ci
56e41f4b71Sopenharmony_ci```ts
57e41f4b71Sopenharmony_ci// xxx.ets
58e41f4b71Sopenharmony_ciimport { promptAction } from '@kit.ArkUI';
59e41f4b71Sopenharmony_ci
60e41f4b71Sopenharmony_ci@Entry
61e41f4b71Sopenharmony_ci@Component
62e41f4b71Sopenharmony_cistruct RadioExample {
63e41f4b71Sopenharmony_ci  @State Rst:promptAction.ShowToastOptions = {'message': 'Ringing mode.'}
64e41f4b71Sopenharmony_ci  @State Vst:promptAction.ShowToastOptions = {'message': 'Vibration mode.'}
65e41f4b71Sopenharmony_ci  @State Sst:promptAction.ShowToastOptions = {'message': 'Silent mode.'}
66e41f4b71Sopenharmony_ci  build() {
67e41f4b71Sopenharmony_ci    Row() {
68e41f4b71Sopenharmony_ci      Column() {
69e41f4b71Sopenharmony_ci        Radio({ value: 'Radio1', group: 'radioGroup' }).checked(true)
70e41f4b71Sopenharmony_ci          .height(50)
71e41f4b71Sopenharmony_ci          .width(50)
72e41f4b71Sopenharmony_ci          .onChange((isChecked: boolean) => {
73e41f4b71Sopenharmony_ci            if(isChecked) {
74e41f4b71Sopenharmony_ci              // Switch to the ringing mode.
75e41f4b71Sopenharmony_ci              promptAction.showToast(this.Rst)
76e41f4b71Sopenharmony_ci            }
77e41f4b71Sopenharmony_ci          })
78e41f4b71Sopenharmony_ci        Text('Ringing')
79e41f4b71Sopenharmony_ci      }
80e41f4b71Sopenharmony_ci      Column() {
81e41f4b71Sopenharmony_ci        Radio({ value: 'Radio2', group: 'radioGroup' })
82e41f4b71Sopenharmony_ci          .height(50)
83e41f4b71Sopenharmony_ci          .width(50)
84e41f4b71Sopenharmony_ci          .onChange((isChecked: boolean) => {
85e41f4b71Sopenharmony_ci            if(isChecked) {
86e41f4b71Sopenharmony_ci              // Switch to the vibration mode.
87e41f4b71Sopenharmony_ci              promptAction.showToast(this.Vst)
88e41f4b71Sopenharmony_ci            }
89e41f4b71Sopenharmony_ci          })
90e41f4b71Sopenharmony_ci        Text('Vibration')
91e41f4b71Sopenharmony_ci      }
92e41f4b71Sopenharmony_ci      Column() {
93e41f4b71Sopenharmony_ci        Radio({ value: 'Radio3', group: 'radioGroup' })
94e41f4b71Sopenharmony_ci          .height(50)
95e41f4b71Sopenharmony_ci          .width(50)
96e41f4b71Sopenharmony_ci          .onChange((isChecked: boolean) => {
97e41f4b71Sopenharmony_ci            if(isChecked) {
98e41f4b71Sopenharmony_ci              // Switch to the silent mode.
99e41f4b71Sopenharmony_ci              promptAction.showToast(this.Sst)
100e41f4b71Sopenharmony_ci            }
101e41f4b71Sopenharmony_ci          })
102e41f4b71Sopenharmony_ci        Text('Silent')
103e41f4b71Sopenharmony_ci      }
104e41f4b71Sopenharmony_ci    }.height('100%').width('100%').justifyContent(FlexAlign.Center)
105e41f4b71Sopenharmony_ci  }
106e41f4b71Sopenharmony_ci}
107e41f4b71Sopenharmony_ci```
108e41f4b71Sopenharmony_ci
109e41f4b71Sopenharmony_ci
110e41f4b71Sopenharmony_ci![en-us_image_0000001562700457](figures/en-us_image_0000001562700457.png)
111