Radio
Demos
Sizes
Available size variant for the ui
prop: small
.
<template>
<article>
<section>
<veui-radio :checked.sync="normal">
Normal size
</veui-radio>
<veui-radio
:checked.sync="small"
ui="small"
>
Small size
</veui-radio>
</section>
<section>
<veui-button
ui="small"
@click="reset"
>
Reset
</veui-button>
</section>
</article>
</template>
<script>
import { Radio, Button } from 'veui'
export default {
components: {
'veui-radio': Radio,
'veui-button': Button
},
data () {
return {
normal: false,
small: false
}
},
methods: {
reset () {
this.normal = false
this.small = false
}
}
}
</script>
Setting value
Use the value
prop to specify the value bound to model
prop (used for 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>
API
Props
Name | Type | Default | Description | ||||
---|---|---|---|---|---|---|---|
ui | string | - | Style variants.
| ||||
model | * | - |
The value of the checked item, being | ||||
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.