@vx-components/checkbox v0.1.1
vx-checkbox
A VxCheckbox Component
Install
npm install --save @vx-components/checkboxVxCheckbox API
props
v-modelBoolean (optional)default: falseThis Boolean property indicates that the control is selected by default, otherwise it is ignored. Use this directive to create two-way data bindings with the component. It indicates that the control is checked or not.valueString (optional) The initial value of the control.idString (optional) Defines a unique identifier (ID) which must be unique in the whole document.labelString (optional) The label of the control.nameString (optional) The name of the control.labelString (optional) The label associated with a control.autofocusBoolean (optional) This Boolean property lets you specify that a form control should have input focus when the page loads, unless the user overrides it, for example by typing in a different control.disabledBoolean (optional)default: falseThis Boolean property indicates that the user cannot interact with the control.titleString (optional) Contains a text representing advisory information related to the element it belongs to. It's also use to display an error message when the input is invalid.requiredBoolean (optional)default: falseThis property specifies that the user must fill in a value before submitting a form.data-class-errorString (optional)default: 'uk-form-danger'
events
invalidFired when a submittable element has been checked and doesn't satisfy its constraints. The validity of submittable elements is checked before submitting their owner form.inputFired when the checked value is changed.changeFired when a change to the initial element's value is committed by the user. Unlike theinputevent, the change event is not necessarily fired for each change to an element's value.
methods
setError()Set a message errorclearError()clear the message error
Usage
<template>
<vx-checkbox v-model="checked"
:value="value" :label="label" @input="onChange" />
</template>
<script>
import VxCheckbox from '@vx-components/checkbox/vx.vue'
export default {
data: () => ({
checked: true,
value: 'agree',
label: 'Recieve daily update'
}),
methods: {
onChange (e) {
// this.checked contains the new checkbox state
}
},
components: { VxCheckbox }
}
</script>License
Under the MIT license. See LICENSE file for more details.
8 years ago