Checkbox
Examples
Size variants
Available ui
prop values: s
/ m
.
Use the indeterminate
prop to put the checkbox in indeterminate state.
<template>
<article>
<section>
<veui-checkbox
v-model="checked"
class="checkbox"
:ui="size"
:indeterminate.sync="indeterminate"
>
Checked: {{ checked }}
</veui-checkbox>
</section>
<section>
<veui-checkbox
v-model="small"
class="checkbox"
ui="s"
>
Small
</veui-checkbox>
<veui-checkbox
v-model="indeterminate"
class="checkbox"
ui="s"
>
Indeterminate
</veui-checkbox>
</section>
</article>
</template>
<script>
import { Checkbox } from 'veui'
export default {
components: {
'veui-checkbox': Checkbox
},
data () {
return {
checked: false,
indeterminate: false,
small: false
}
},
computed: {
size () {
return this.small ? 's' : ''
}
}
}
</script>
<style lang="less" scoped>
.checkbox {
& + & {
margin-left: 20px;
}
}
</style>
True/false values
You can set the v-model
value by using the true-value
and false-value
props.
State: Not confirmed
<template>
<article>
<veui-checkbox
v-model="status"
true-value="CONFIRMED"
false-value="UNCONFIRMED"
>
I've read the agreement
</veui-checkbox>
<p>State: {{ statusMap[status] }}</p>
</article>
</template>
<script>
import { Checkbox } from 'veui'
const STATUS_MAP = {
CONFIRMED: 'Confirmed',
UNCONFIRMED: 'Not confirmed'
}
export default {
components: {
'veui-checkbox': Checkbox
},
data () {
return {
status: 'UNCONFIRMED',
statusMap: STATUS_MAP
}
}
}
</script>
API
Props
Name | Type | Default | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
ui | string | - | Preset styles.
| ||||||
checked | boolean | false |
Whether the checkbox is checked. | ||||||
value | * | - | When v-model is bound to an array, represents the value of the current checkbox. | ||||||
true-value | * | true | The value corresponding to the checked state. | ||||||
false-value | * | false | The value corresponding to the unchecked state. | ||||||
indeterminate | boolean | false | Whether the checkbox is in the indeterminate state. | ||||||
disabled | boolean | false | Whether the checkbox is disabled. | ||||||
readonly | boolean | false | Whether the checkbox is readonly. |
Slots
Name | Description |
---|---|
default | The descriptive text of the checkbox, which toggles the selection state when clicked. No default content. |
Events
Name | Description |
---|---|
change | Triggered when the user toggles the selection state. The callback parameter is (checked: boolean) . checked indicates whether the checkbox is currently selected. |
input |
Triggered after the selection state changes. The callback parameter is In addition,
The callback parameters are the corresponding native event objects. |
Icons
Name | Description |
---|---|
checked | Checked state. |
indeterminate | Indeterminate state. |