npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@tanzhenxing/zx-checkbox

v1.0.7

Published

多选框组件,用于在一组备选项中进行多选

Readme

zx-checkbox 多选框组件

在一组备选项中进行多选。

使用示例

基础用法

单独使用可以表示两种状态之间的切换,写在标签中的内容为 checkbox 按钮后的介绍。

<template>
  <view>
    <zx-checkbox v-model="checked1" label="选项 1" />
    <zx-checkbox v-model="checked2" label="选项 2" />
  </view>
</template>

<script setup>
import { ref } from 'vue';

const checked1 = ref(true);
const checked2 = ref(false);
</script>

禁用状态

多选框不可用状态。

<zx-checkbox v-model="checked1" disabled label="禁用" />
<zx-checkbox v-model="checked2" label="未禁用" />

多选框组

适用于多个勾选框绑定到同一个数组的情景,通过是否勾选来表示这一组选项中选中的项。

<template>
  <zx-checkbox-group v-model="checkList">
    <zx-checkbox label="选项 A" value="A" />
    <zx-checkbox label="选项 B" value="B" />
    <zx-checkbox label="选项 C" value="C" />
    <zx-checkbox label="禁用" value="D" disabled />
    <zx-checkbox label="选中且禁用" value="E" disabled />
  </zx-checkbox-group>
</template>

<script setup>
import { ref } from 'vue';

const checkList = ref(['E', 'A']);
</script>

中间状态

indeterminate 属性用以表示 checkbox 的不确定状态,一般用于实现全选的效果。

<template>
  <zx-checkbox 
    v-model="checkAll" 
    :indeterminate="isIndeterminate"
    @change="handleCheckAllChange"
    label="全选" 
  />
  <zx-checkbox-group 
    v-model="checkedCities" 
    @change="handleCheckedCitiesChange"
  >
    <zx-checkbox v-for="city in cities" :key="city" :label="city" :value="city">
      {{ city }}
    </zx-checkbox>
  </zx-checkbox-group>
</template>

<script setup>
import { ref } from 'vue';

const checkAll = ref(false);
const isIndeterminate = ref(true);
const checkedCities = ref(['上海', '北京']);
const cities = ['上海', '北京', '广州', '深圳'];

const handleCheckAllChange = (val) => {
  checkedCities.value = val ? cities : [];
  isIndeterminate.value = false;
};
const handleCheckedCitiesChange = (value) => {
  const checkedCount = value.length;
  checkAll.value = checkedCount === cities.length;
  isIndeterminate.value = checkedCount > 0 && checkedCount < cities.length;
};
</script>

带有边框

设置 border 属性可以渲染为带有边框的多选框。

<zx-checkbox v-model="checked1" label="选项1" border />
<zx-checkbox v-model="checked2" label="选项2" border />

属性

| 参数 | 说明 | 类型 | 默认值 | | -------------- | ---------------------------------------------------- | -------------------------- | ---------- | | v-model | 绑定值 | boolean / array | false | | name | checkbox 的名称 | string / number / boolean | - | | value | checkbox 的值 | string / number / boolean | - | | label | 显示的标签文本 | string / number | - | | shape | 形状,可选值为 square 或 circle | string | square | | size | 整体的大小 | string / number | 36rpx | | disabled | 是否禁用 | boolean | false | | indeterminate | 设置不确定状态,仅负责样式控制 | boolean | false | | active-color | 选中状态下的颜色 | string | #2979ff | | inactive-color | 未选中的颜色 | string | #c8c9cc | | icon-size | 图标的大小 | string / number | 24rpx | | icon-color | 图标颜色 | string | #ffffff | | label-size | label的字体大小 | string / number | 28rpx | | label-color | label的颜色 | string | #303133 | | label-disabled | 是否禁止点击提示语选中复选框 | boolean | false | | border | 是否显示边框 | boolean | false | | true-value | 选中时的值 | string / number / boolean | true | | false-value | 未选中时的值 | string / number / boolean | false | | custom-style | 定义需要用到的外部样式 | object | {} |

事件

| 事件名 | 说明 | 回调参数 | | ------- | ------------------------ | -------- | | change | 当绑定值变化时触发的事件 | 更新后的值 |

插槽

| 名称 | 说明 | | ------- | ------------------- | | default | 自定义默认内容 | | icon | 自定义图标 |