Checkbox

Single selection among multiple options

Use

Basic Use

Set data attribute will automatic generate options

<template>
  <pro-checkbox
    v-model="checkbox"
    :data="data"
  />
</template>

<script>
import { defineComponent, ref } from 'vue'

export default defineComponent({
  setup() {
    const checkbox = ref([])
    const data = ref([
      { value: 'Go', label: 'go' },
      { value: 'JavaScript', label: 'javascript' },
      { value: 'Python', label: 'python' },
      { value: 'Dart', label: 'dart' },
      { value: 'V', label: 'v' },
    ])

    return {
      checkbox,
      data,
    }
  },
})
</script>

Disabled State

Set the disabled attribute in prop data

<template>
  <pro-checkbox
    v-model="checkbox"
    :data="list"
  />
</template>

<script>
import { defineComponent, ref } from 'vue'

export default defineComponent({
  setup() {
    const checkbox = ref([])
    const list = ref([
      { value: 'Go', label: 'go', disabled: true },
      { value: 'JavaScript', label: 'javascript' },
      { value: 'Python', label: 'python' },
      { value: 'Dart', label: 'dart' },
      { value: 'V', label: 'v' },
    ])

    return {
      checkbox,
      list,
    }
  },
})
</script>

Configure key of binding data

Set config attribute. value- v-model bind key; label- display key; disabled- Disabled key; name- name key

<template>
  <pro-checkbox
    v-model="checkbox"
    :data="data"
    :config="config"
  />
</template>

<script>
import { defineComponent, ref } from 'vue'

export default defineComponent({
  setup() {
    const checkbox = ref([])
    const config = ref({ value: 'label', label: 'value' })
    const data = ref([
      { value: 'Go', label: 'go' },
      { value: 'JavaScript', label: 'javascript' },
      { value: 'Python', label: 'python' },
      { value: 'Dart', label: 'dart' },
      { value: 'V', label: 'v' },
    ])

    return {
      checkbox,
      config,
      data,
    }
  },
})
</script>

Button style

use pro-checkbox-button then checkbox with button styles

<template>
  <pro-checkbox-button
    v-model="checkboxbutton"
    :data="data"
  />
</template>

<script>
import { defineComponent, ref } from 'vue'

export default defineComponent({
  setup() {
    const checkboxbutton = ref([])
    const data = ref([
      { value: 'Go', label: 'go' },
      { value: 'JavaScript', label: 'javascript' },
      { value: 'Python', label: 'python' },
      { value: 'Dart', label: 'dart' },
      { value: 'V', label: 'v' },
    ])

    return {
      checkboxbutton,
      data,
    }
  },
})
</script>

Checkbox Props

NameDescriptionTypeOptionsDefault
v-modelbinding valuearray--
databinding dataarray--
configconfig the key of dataobject-{ value: ‘value’, label: ‘label’, disabled: ‘disabled’, name: ‘name’ }
sizecomponent sizestringlarge / default /small-
disabledwhether disabledboolean-false
minminimum number of checkbox checkednumber--
maxmaximum number of checkbox checkednumber--
text-colorfont color when button is activestring-#ffffff
fillborder and background color when button is activestring-#409EFF
validate-eventwhether to trigger form validationboolean-true

Checkbox Events

NameDescriptionParameters
changetriggers when the binding value changesthe updated value

CheckboxButton

Checkbox with button styles

CheckboxButton Props

NameDescriptionTypeOptionsDefault
v-modelbinding valuearray--
databinding dataarray--
configconfig the key of dataobject-{ value: ‘value’, label: ‘label’, disabled: ‘disabled’, name: ‘name’ }
sizecomponent sizestringlarge / default /small-
disabledwhether disabledboolean-false
minminimum number of checkbox checkednumber--
maxmaximum number of checkbox checkednumber--
text-colorfont color when button is activestring-#ffffff
fillborder and background color when button is activestring-#409EFF
validate-eventwhether to trigger form validationboolean-true

CheckboxButton Events

NameDescriptionParameters
changetriggers when the binding value changesthe updated value