RadioGroup
Examples
Size variants
Available ui
prop values: s
/ m
.
Normal size
Checked: -
Small size
Checked: -
<template>
<article>
<section>
<h4>Normal size</h4>
<veui-radio-group
v-model="flavor"
:items="flavors"
/>
<p>Checked: {{ readable }}</p>
</section>
<section>
<h4>Small size</h4>
<veui-radio-group
v-model="flavor"
ui="s"
:items="flavors"
/>
<p>Checked: {{ readable }}</p>
</section>
</article>
</template>
<script>
import { RadioGroup } from 'veui'
export default {
components: {
'veui-radio-group': RadioGroup
},
data () {
return {
flavor: null,
flavors: [
{ value: 'LATTE', label: 'Latte' },
{ value: 'MOCHA', label: 'Mocha' },
{ value: 'AMERICANO', label: 'Americano' }
]
}
},
computed: {
flavorLabelMap () {
return this.flavors.reduce((map, { value, label }) => {
map[value] = label
return map
}, {})
},
readable () {
return this.flavorLabelMap[this.flavor] || '-'
}
}
}
</script>
<style lang="less" scoped>
section {
margin-bottom: 20px;
}
h4 {
margin-top: 0;
}
</style>
Additional description
Set the desc
property in the data source project or specify additional description through the desc
slot. The additional description will be displayed on hover.
<template>
<article>
<section>
<veui-radio-group
v-model="flavor"
:items="flavors"
/>
</section>
<section>
<veui-radio-group
v-model="flavor"
:items="flavors"
>
<template #desc="{ desc, label }">
{{ desc || `a description for ${label}` }}
</template>
</veui-radio-group>
</section>
</article>
</template>
<script>
import { RadioGroup } from 'veui'
export default {
components: {
'veui-radio-group': RadioGroup
},
data () {
return {
flavor: null,
flavors: [
{ value: 'LATTE', label: 'Latte', desc: 'a description for latte.' },
{ value: 'MOCHA', label: 'Mocha', desc: 'a description for mocha.' },
{ value: 'AMERICANO', label: 'Americano' }
]
}
}
}
</script>
<style lang="less" scoped>
section {
margin-bottom: 20px;
}
h4 {
margin-top: 0;
}
</style>
API
Props
Name | Type | Default | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ui | string | - | Predefined style.
| |||||||||||||||
items | Array<Object> | [] | Radio group data source, with project type
| |||||||||||||||
value | * | - |
The | |||||||||||||||
disabled | boolean | false | Whether it is disabled. | |||||||||||||||
readonly | boolean | false | Whether it is read-only. |
Slots
Name | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
item | Option description text area. Default content:
In addition, other properties in the data item in | |||||||||||||||
desc | Additional description information for the button, with slot props same as the item slot. |
Events
Name | Description |
---|---|
change |
Triggered after the selection state changes, with the callback parameter |