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

@mshafiqyajid/react-checkbox

v0.4.0

Published

Headless checkbox hook and styled component for React. Indeterminate state, accessible, keyboard-friendly, fully typed.

Readme

@mshafiqyajid/react-checkbox

Headless checkbox hook and styled component for React. Indeterminate state, helper description, error state, card variant, accessible, keyboard-friendly, fully typed.

Full docs →

Install

npm install @mshafiqyajid/react-checkbox

Headless usage

import { useCheckbox } from "@mshafiqyajid/react-checkbox";

function MyCheckbox() {
  const { checkboxProps, isChecked } = useCheckbox({ defaultChecked: false });
  return <button {...checkboxProps}>{isChecked ? "✓" : ""}</button>;
}

Styled usage

import { CheckboxStyled } from "@mshafiqyajid/react-checkbox/styled";
import "@mshafiqyajid/react-checkbox/styles.css";

<CheckboxStyled
  label="I agree to the terms"
  description="You can revoke this any time in settings."
  required
  tone="primary"
/>

Indeterminate

Pass "indeterminate" (or defaultChecked="indeterminate") for tri-state. Clicking from indeterminate moves to checked.

<CheckboxStyled checked="indeterminate" onChange={(c) => /* ... */} />

Card variant

card renders the row inside a bordered, clickable card — handy for large form options.

<CheckboxStyled
  card
  label="Email me product updates"
  description="At most twice a month — never spam."
/>

Validation

Pass an error message to flip tone to danger and render a message under the row.

<CheckboxStyled
  checked={agree}
  onChange={setAgree}
  label="I accept the terms"
  required
  error={!agree ? "You must accept to continue" : undefined}
/>

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | checked | boolean \| "indeterminate" | — | Controlled state | | defaultChecked | boolean \| "indeterminate" | false | Uncontrolled initial state | | onChange | (checked: boolean) => void | — | Always emits boolean | | size | "sm" \| "md" \| "lg" | "md" | Size | | tone | "neutral" \| "primary" \| "success" \| "danger" | "primary" | Color when checked | | label | ReactNode | — | Label | | description | ReactNode | — | Helper text below the label | | error | ReactNode | — | Error message — flips tone to danger | | labelPosition | "left" \| "right" | "right" | Label side | | card | boolean | false | Bordered card with whole-row click | | required | boolean | false | Append a red asterisk to the label | | disabled | boolean | false | Disable |

What's new in 0.4.0

CheckboxGroup

Group multiple checkboxes into a controlled or uncontrolled fieldset. Each child CheckboxStyled with a value prop automatically participates in the group's selection array.

import { CheckboxGroup, CheckboxStyled } from "@mshafiqyajid/react-checkbox/styled";
import "@mshafiqyajid/react-checkbox/styles.css";

function NotificationPrefs() {
  const [values, setValues] = useState(["email"]);
  return (
    <CheckboxGroup
      label="Notify me about…"
      hint="Choose the updates you want to receive."
      value={values}
      onChange={setValues}
    >
      <CheckboxStyled value="email" label="Email updates" />
      <CheckboxStyled value="sms" label="SMS alerts" />
      <CheckboxStyled value="push" label="Push notifications" />
    </CheckboxGroup>
  );
}

CheckboxGroup props

| Prop | Type | Default | Description | |------|------|---------|-------------| | name | string | — | Shared name for child inputs | | value | string[] | — | Controlled selection | | defaultValue | string[] | [] | Uncontrolled initial selection | | onChange | (values: string[]) => void | — | Called on every toggle | | disabled | boolean | false | Disable all child checkboxes | | label | ReactNode | — | Fieldset legend | | hint | ReactNode | — | Helper text below legend | | error | ReactNode | — | Error message below items | | invalid | boolean | false | Mark all children invalid | | required | boolean | false | Append a red asterisk to the legend |

useCheckboxTree

Manages a tree of checkboxes where parent state is derived from children. A parent is indeterminate when some (not all) of its leaf descendants are checked; it is checked only when all are checked.

import { useCheckboxTree } from "@mshafiqyajid/react-checkbox";
import { CheckboxStyled } from "@mshafiqyajid/react-checkbox/styled";

const nodes = [
  {
    id: "fruits",
    label: "Fruits",
    children: [
      { id: "apple", label: "Apple" },
      { id: "banana", label: "Banana" },
    ],
  },
];

function TreeExample() {
  const { getCheckboxProps, toggleAll } = useCheckboxTree(nodes);
  return (
    <div>
      <button onClick={toggleAll}>Toggle all</button>
      <CheckboxStyled label="Fruits" {...getCheckboxProps("fruits")} />
      <div style={{ paddingLeft: 24 }}>
        <CheckboxStyled label="Apple" {...getCheckboxProps("apple")} />
        <CheckboxStyled label="Banana" {...getCheckboxProps("banana")} />
      </div>
    </div>
  );
}

Animated SVG checkmark draw

The checkmark path now draws via stroke-dashoffset over 180 ms ease-out when a checkbox is checked. The indeterminate bar morphs in similarly. Both honour prefers-reduced-motion.

License

MIT