# Radio Group (radio-group)

# Description

It is used to group radio buttons in the form, and provides multiple operation methods for related radio buttons. Used with radio.

# Usage result

# How to use it

Importing a component in a .ux file:

<import
  name="q-radio-group"
  src="qaui/src/components/radio-group/index"
></import>
1
2
3
4

# Example

<template>
  <div class="qaui-wrap">
    <text class="title">Default style</text>
    <q-radio-group id="myGroup1" current="{{current}}" onchange="handleChange">
      <q-radio
        group="myGroup1"
        for="{{list}}"
        value="{{$item.value}}"
        checked="{{$item.checked}}"
      ></q-radio>
    </q-radio-group>
    <text class="title">list style</text>
    <q-radio-group id="myGroup2" current="{{current}}" onchange="handleChange">
      <q-radio
        group="myGroup2"
        type="list"
        for="{{list}}"
        value="{{$item.value}}"
        checked="{{$item.checked}}"
      ></q-radio>
    </q-radio-group>
    <text class="title">dot style</text>
    <q-radio-group id="myGroup3" current="{{current}}" onchange="handleChange">
      <q-radio
        group="myGroup3"
        type="dot"
        for="{{list}}"
        value="{{$item.value}}"
        checked="{{$item.checked}}"
      ></q-radio>
    </q-radio-group>
  </div>
</template>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
export default {
  data() {
    return {
      list: [
        {
          id: 1,
          value: 'Single option #1',
        },
        {
          id: 2,
          value: 'Single option #2',
          checked: true,
        },
        {
          id: 3,
          value: 'Single option #3',
        },
      ],
      current: 'Single option #2',
    }
  },
  handleChange({ detail }) {
    this.current = detail.value
  },
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
.qaui-wrap {
  flex-direction: column;
  align-items: center;
  background-color: #f2f2f2;
  padding: 10px 0;
  .title {
    height: 40px;
    font-size: 14px;
    align-self: flex-start;
    padding-left: 20px;
  }
}
1
2
3
4
5
6
7
8
9
10
11
12

# API

# Component Properties

Attribute Type Value by default Description
current String - Value of the selected radio
id String - The id of the group, which is used to differentiate groups (mandatory).

# Component Events

Event name Event description Value returned
change Change of value {current:current, value:value}