Skip to content

CheckButton Checkbox Button Component ​

This component internally re-encapsulates the tag component to implement button-style checkboxes and radio buttons

📌 Platform Differences ​

APP(vue)H5WeChat Mini ProgramAlipay Mini Program
✔✔✔✔

🏯 Basic Usage Example ​

html
<template>
    <!-- 全局使用 -->
    <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: '老师', value: 0 },
        { label: '护士', value: 1 },
        { label: '空姐', value: 2 },
        { label: '作家', value: 3 },
        { label: '网红', value: 4 },
        { label: '科学家', 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: '老师', value: 0 },
    { label: '护士', value: 1 },
    { label: '空姐', value: 2 },
    { label: '作家', value: 3 },
    { label: '网红', value: 4 },
    { label: '科学家', 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: '老师', value: 0 },
    { label: '护士', value: 1 },
    { label: '空姐', value: 2 },
    { label: '作家', value: 3 },
    { label: '网红', value: 4 },
    { label: '科学家', 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: '老师', value: 0 },
    { label: '护士', value: 1 },
    { label: '空姐', value: 2 },
    { label: '作家', value: 3 },
    { label: '网红', value: 4 },
    { label: '科学家', 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: '老师', value: 0 },
    { label: '护士', value: 1 },
    { label: '空姐', value: 2 },
    { label: '作家', value: 3 },
    { label: '网红', value: 4 },
    { label: '科学家', 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: '老师', value: 0 },
    { label: '护士', value: 1 },
    { label: '空姐', value: 2 },
    { label: '作家', value: 3 },
    { label: '网红', value: 4 },
    { label: '科学家', value: 5 },
]);

API ​

PropDescriptionTypeDefault
v-modelSelected value[1]string|number| (string|number)[]-
columnsList dataarray-
fieldNamesCustom keys mapped to 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 grid-template-columnsstringrepeat(3, 1fr)
gapSets the row spacing, numeric values use px by defaultstring| 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 text contentstring-
valueValuestring-
checkedWhether selectedboolean-
disabledWhether disabledboolean-

API ​

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

Events ​

Event NameDescriptionCallback Parameters
changeTriggered on selection-

Slots ​

Slot NameDescriptionReceived Values
name--

CSS Variables ​

VariableDescriptionDefault
--hy-check-button-border-widthBorder width2rpx
--hy-check-button-hover-opacityPressed opacity0.8
--hy-check-button-padding-smallsmall padding10rpx 16rpx
--hy-check-button-padding-mediummedium padding16rpx 20rpx
--hy-check-button-padding-largelarge padding20rpx 24rpx
--hy-check-button-font-size-smallsmall font size (line height follows accordingly)Follows --hy-font-size-sm (24rpx)
--hy-check-button-font-size-mediummedium font size (line height follows accordingly)Follows --hy-font-size-base (28rpx)
--hy-check-button-font-size-largelarge font size (line height follows accordingly)Follows --hy-font-size-md (32rpx)
--hy-check-button-radius-circleCircle border radiusFollows --hy-radius-semicircle (100px)
--hy-check-button-radius-squareSquare border radiusFollows --hy-radius-sm (8rpx)
--hy-check-button-disabled-colorDisabled text colorFollows --hy-text-color--disabled
--hy-check-button-disabled-border-colorDisabled state border colorFollows --hy-background--disabled
12:33
battery

  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: Semi-circular on both sides; square: Square with rounded corners ↩︎