Radio
Demos
Sizes
Available size variant for the ui
prop: s
/ m
.
<template>
<article>
<section>
<veui-radio
v-model="size"
value="m"
:ui="size"
name="size"
>
Normal size
</veui-radio>
<veui-radio
v-model="size"
value="s"
:ui="size"
name="size"
>
Small size
</veui-radio>
</section>
</article>
</template>
<script>
import { Radio } from 'veui'
export default {
components: {
'veui-radio': Radio
},
data () {
return {
size: 'm'
}
}
}
</script>
<style lang="less" scoped>
.veui-radio {
margin-right: 20px;
}
section {
margin-bottom: 20px;
}
</style>
Setting value
Use the value
prop to specify the value bound to v-model
.
Selected: -
<template>
<article>
<veui-radio
v-for="({ value, label }) in flavors"
:key="value"
v-model="flavor"
:value="value"
>
{{ label }}
</veui-radio>
<p>Selected: {{ flavorLabelMap[flavor] || '-' }}</p>
</article>
</template>
<script>
import { Radio } from 'veui'
export default {
components: {
'veui-radio': Radio
},
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
}, {})
}
}
}
</script>
<style lang="less" scoped>
.veui-radio {
margin-right: 20px;
}
</style>
API
Props
Name | Type | Default | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
ui | string= | - | Style variants.
| ||||||
checked | boolean | false |
Whether the checkbox is checked. | ||||||
value | * | true | The value of the radio. | ||||||
disabled | boolean= | false | Whether the radio is disabled. | ||||||
readonly | boolean= | false | Whether the radio is read-only. |
Slots
Name | Description |
---|---|
default | The label text of the radio. The radio is selected when the label is clicked. Displays nothing by default. |
Events
Name | Description |
---|---|
change | Triggered when user checks the radio. The callback parameter list is (checked: boolean) . checked denotes whether the radio is checked. |
input |
Triggered when the check state is changed. The callback parameter list is |
Additionally, Radio
exposes the following native events:
auxclick
, click
, contextmenu
, dblclick
, mousedown
, mouseenter
, mouseleave
, mousemove
, mouseover
, mouseout
, mouseup
, select
, wheel
, keydown
, keypress
, keyup
, focus
, blur
, focusin
, focusout
.
The callback parameter is the corresponding native event object for all events above.