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

@sea-lion/react-checkbox

v0.3.0

Published

Checkbox 是一个复选框组件,用于在表单中进行多选操作。支持选中、未选中、半选状态,多种颜色主题和禁用状态。

Readme

react-checkbox

Checkbox 是一个复选框组件,用于在表单中进行多选操作。支持选中、未选中、半选状态,多种颜色主题和禁用状态。

安装

pnpm add @sea-lion/react-checkbox
# 或者
npm install @sea-lion/react-checkbox
yarn add @sea-lion/react-checkbox

使用

在代码中引入组件:

import { Checkbox } from '@sea-lion/react-checkbox';

基本用法

<Checkbox />
<Checkbox defaultChecked />
<Checkbox checked={checked} onCheckedChange={setChecked} />
<Checkbox checked="indeterminate" />

不同状态

Checkbox 支持三种状态:选中、未选中和半选(indeterminate)。

<Flex direction="column" gap="4">
  <Flex align="center" gap="2">
    <Checkbox defaultChecked />
    <Text>选中状态</Text>
  </Flex>

  <Flex align="center" gap="2">
    <Checkbox checked="indeterminate" />
    <Text>半选状态</Text>
  </Flex>

  <Flex align="center" gap="2">
    <Checkbox disabled />
    <Text color="gray">禁用状态</Text>
  </Flex>

  <Flex align="center" gap="2">
    <Checkbox disabled defaultChecked />
    <Text color="gray">禁用且选中</Text>
  </Flex>
</Flex>

不同颜色

通过 color 属性设置复选框颜色主题:

<Flex direction="column" gap="4">
  {['gray', 'gold', 'bronze', 'red', 'blue', 'green'].map((color) => (
    <Flex key={color} align="center" gap="2">
      <Checkbox color={color} defaultChecked />
      <Text>{color} 主题</Text>
    </Flex>
  ))}
</Flex>

高对比度

通过 highContrast 属性启用高对比度模式,使复选框在深色背景下更清晰:

<Flex direction="column" gap="4">
  {['gray', 'gold', 'bronze', 'red', 'blue', 'green'].map((color) => (
    <Flex key={color} align="center" gap="2">
      <Checkbox color={color} highContrast defaultChecked />
      <Text>高对比度 {color}</Text>
    </Flex>
  ))}
</Flex>

表单应用

在表单中受控使用 Checkbox:

const [checked, setChecked] = React.useState(false);

<Flex direction="column" gap="4">
  <Text size="3" weight="bold">用户协议</Text>

  <Flex align="start" gap="2">
    <Checkbox
      checked={checked}
      onCheckedChange={() => setChecked(!checked)}
    />
    <Text size="2">我已阅读并同意《用户协议》和《隐私政策》</Text>
  </Flex>

  <button disabled={!checked}>下一步</button>
</Flex>

Props / API

Checkbox

| 参数 | 说明 | 类型 | 默认值 | |------|------|------|--------| | checked | 复选框的选中状态 | boolean \| "indeterminate" | - | | defaultChecked | 初始选中状态(非受控) | boolean | false | | onCheckedChange | 选中状态变化时的回调 | (checked: boolean \| "indeterminate") => void | - | | disabled | 是否禁用 | boolean | false | | color | 颜色主题 | "gray" \| "gold" \| "bronze" \| "red" \| "blue" \| "green" | - | | highContrast | 是否使用高对比度 | boolean | false | | size | 复选框尺寸 | "1" \| "2" \| "3" | "2" | | name | 表单字段名称 | string | - | | value | 表单字段值 | string | - | | required | 是否必填 | boolean | false |

查看更多

参考 Radix UI 官方文档 获取完整 API 与设计规范。