Skip to content

CheckButton Checkbox Button Component

This component internally implements checkbox and radio buttons through secondary encapsulation of the tag component

📌 Platform Differences

APP(vue)H5WeChat Mini ProgramAlipay Mini Program

🏯 Basic Usage Example

html
<template>
    <!-- Global usage -->
    <hy-check-button v-model="value" :columns="columns"></hy-check-button>
</template>

<script lang="ts" setup>
    import { reactive, ref } from 'vue';

    const value = ref('');
    const columns = reactive([
        { label: 'Teacher', value: 0 },
        { label: 'Nurse', value: 1 },
        { label: 'Flight Attendant', value: 2 },
        { label: 'Writer', value: 3 },
        { label: 'Influencer', value: 4 },
        { label: 'Scientist', value: 5 },
    ]);
</script>

Theme Color

  • Configure the theme color via type
    • primary: Info button (default)
    • success: Primary button
    • info: Default button
    • warning: Warning button
    • error: Danger button
html
<hy-check-button v-model="value" :columns="columns" :type="type"></hy-check-button>
ts
import { reactive, ref } from 'vue';

const value = ref('');
const type = ref<HyApp.ThemeType>('primary');

const columns = reactive([
    { label: 'Teacher', value: 0 },
    { label: 'Nurse', value: 1 },
    { label: 'Flight Attendant', value: 2 },
    { label: 'Writer', value: 3 },
    { label: 'Influencer', value: 4 },
    { label: 'Scientist', value: 5 },
]);

Configuring Button Size

  • Configure the button size via size
    • large: Large
    • medium: Medium
    • small: Small
html
<hy-check-button v-model="value" :columns="columns" :type="type"></hy-check-button>
ts
import { reactive, ref } from 'vue';

const value = ref('');
const type = ref<HyApp.SizeType>('medium');

const columns = reactive([
    { label: 'Teacher', value: 0 },
    { label: 'Nurse', value: 1 },
    { label: 'Flight Attendant', value: 2 },
    { label: 'Writer', value: 3 },
    { label: 'Influencer', value: 4 },
    { label: 'Scientist', value: 5 },
]);

Configuring Shape

  • Set the button shape via the shape value;
    • square: Square (default)
    • circle: Rounded
html
<hy-check-button v-model="value" :columns="columns" :shape="shape"></hy-check-button>
ts
import { reactive, ref } from 'vue';

const value = ref('');
const type = ref<HyApp.ShapeType>('square');

const columns = reactive([
    { label: 'Teacher', value: 0 },
    { label: 'Nurse', value: 1 },
    { label: 'Flight Attendant', value: 2 },
    { label: 'Writer', value: 3 },
    { label: 'Influencer', value: 4 },
    { label: 'Scientist', value: 5 },
]);

Radio Button

  • Set selectType to radio
html
<hy-check-button v-model="value" :columns="columns" selectType="radio"></hy-check-button>
ts
import { reactive, ref } from 'vue';

const value = ref('');

const columns = reactive([
    { label: 'Teacher', value: 0 },
    { label: 'Nurse', value: 1 },
    { label: 'Flight Attendant', value: 2 },
    { label: 'Writer', value: 3 },
    { label: 'Influencer', value: 4 },
    { label: 'Scientist', value: 5 },
]);

Checkbox Button

  • Set selectType to checkbox
html
<hy-check-button v-model="value" :columns="columns" selectType="checkbox"></hy-check-button>
ts
import { reactive, ref } from 'vue';

const value = ref([0]);

const columns = reactive([
    { label: 'Teacher', value: 0 },
    { label: 'Nurse', value: 1 },
    { label: 'Flight Attendant', value: 2 },
    { label: 'Writer', value: 3 },
    { label: 'Influencer', value: 4 },
    { label: 'Scientist', value: 5 },
]);

API

PropDescriptionTypeDefault
v-modelSelected value[1]string|number| (string|number)[]-
columnsList dataarray-
fieldNamesCustom keys for columnsobject{label: "label",value: "value",checked: "checked"}
selectTypeSingle or multiple selection[2]checkbox|radiocheckbox
disabledDisabledbooleanfalse
colSets the column layout of child elements, refer to the CSS property value grid-template-columnsstringrepeat(3, 1fr)
gapSets the row spacing; numeric values default to the unit pxstring| number10px
typeTag type[3]error|warning|success |primary|infoprimary
sizeTag size[4]small|medium|largemedium
shapeShape of the tag[5]circle|squaresquare

columns

PropDescriptionTypeDefault
labelDisplayed textstring-
valueValuestring-
checkedWhether selectedboolean-
disabledWhether disabledboolean-

API

PropDescriptionTypeDefault
labelCustom text key of columnsstringlabel
valueCustom value key of columnsstringvalue
checkedCustom checked key of columnsstringchecked

Events

Event NameDescriptionCallback Parameters
changeTriggered on selection-

Slots

Slot NameDescriptionReceived Values
name--
03:29

  1. When selectType is set to radio, v-model must be passed a string/number; when set to checkbox, v-model must be passed an array ↩︎

  2. checkbox: multiple selection; radio: single selection ↩︎

  3. error: #fa3534; warning: #ff9900; success: #19be6b; primary: #2979ff; info: #909399; ↩︎

  4. normal: default size; large: large size; small: small size; ↩︎

  5. circle: semicircular on both ends; square: square with rounded corners ↩︎