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

@john-guerra/search-checkbox

v1.0.0

Published

A reactive widget combining a search box with checkboxes, for selecting from long lists. Select all/none respects the active filter.

Readme

search-checkbox 🔎☑

A reactive widget that pairs a search box with a checkbox list, for selecting from a long list of options.

Its reason to exist: All / None act on the options currently matching the search, not on the whole list. That turns "select the twelve goalkeeping attributes out of these eighty-eight" into two actions instead of twelve.

Install

npm install @john-guerra/search-checkbox

Or from a CDN. The UMD bundle inlines its dependencies, so this one tag is all you need:

<!-- integrity hash added at first npm publish -->
<script src="https://cdn.jsdelivr.net/npm/@john-guerra/[email protected]/dist/SearchCheckbox.min.js"></script>

Pin the version and add integrity/crossorigin once published — an unpinned, unverified CDN tag is a supply-chain hole.

Observable Inputs ships its own stylesheet. Without it the widget works but looks unstyled:

<link
  rel="stylesheet"
  href="https://cdn.jsdelivr.net/npm/@observablehq/[email protected]/dist/index.css"
  integrity="sha384-2Rrhg9mYHabUfNPNAJlfwvKrGsf0pHEBlahVJQEFOyqoVUqB2qgLnFizfFMPX9JO"
  crossorigin="anonymous"
/>

Usage

ES modules

import searchCheckbox from "@john-guerra/search-checkbox";

const widget = searchCheckbox(["Crossing", "Finishing", "HeadingAccuracy"], {
  label: "Attributes",
  value: ["Crossing"],
  height: 200,
});

widget.addEventListener("input", () => console.log(widget.value));
document.body.append(widget);

Vanilla JS

<div id="target"></div>
<label>You selected: <output id="output"></output></label>

<!-- integrity hash added at first npm publish -->
<script src="https://cdn.jsdelivr.net/npm/@john-guerra/[email protected]/dist/SearchCheckbox.min.js"></script>
<script>
  const widget = SearchCheckbox([1, 2, 3, 4]);
  document.querySelector("#target").append(widget);

  const show = () => (document.querySelector("#output").value = widget.value);
  widget.addEventListener("input", show);
  show();
</script>

Observable

import { default as searchCheckbox } from "@john-guerra/search-checkbox";
viewof selected = searchCheckbox(data, { label: "Variables", value: data })

Binding to another input

import * as Inputs from "@observablehq/inputs";

const source = searchCheckbox(data, { label: "Skills" });
const target = Inputs.checkbox(data);

// Outside Observable, pass a never-resolving invalidation. Inputs.bind
// defaults it to disposal(target), which resolves immediately when the element
// is not inside an `.observablehq` cell — and on resolution bind tears down the
// source→target direction.
Inputs.bind(target, source, new Promise(() => {}));

See example/bind.html for a working page.

API

searchCheckbox(data, options);

data is any iterable of options. Returns a <div class="search-checkbox"> element with a .value property and an input event.

| Option | Default | Meaning | | ------------------- | -------- | -------------------------------------------------------------- | | value | [] | Initially selected options. Entries not in data are ignored. | | label | — | Label above the widget; also the search box's accessible name. | | height | 300 | Max height in px of the scrolling checkbox area. | | format | d => d | Format an option for display. | | optionsCheckboxes | — | Replace the options forwarded to Inputs.checkbox. | | optionsSearch | — | Merged over the default Inputs.search options. | | debug | false | Log selection changes to the console. |

Any other option is forwarded to Inputs.checkbox.

.value — get the array of selected options, or assign one. Assigning refreshes the checkboxes and the counter but does not fire an input event; only user actions do. That is what keeps Inputs.bind from double-firing.

input event — dispatched on every user-driven selection change, exactly once. Typing in the search box does not fire it, because searching changes what is visible, not what is selected.

Search behavior

The search matches a term anywhere in the text, including mid-word: typing Accuracy finds both HeadingAccuracy and FKAccuracy. Observable's default search filter anchors at word start and finds neither. That filter is exported separately if you want it elsewhere:

import { fullSearchFilter } from "@john-guerra/search-checkbox/filter";

Multiple whitespace-separated terms are ANDed.

Differences from the notebook

This is a behavior-faithful port of @john-guerra/search-checkbox@509. Ten intentional differences, none of which change how the widget looks:

  1. Filtering is O(n) per keystroke instead of O(n²).
  2. The reflow after a change uses offsetHeight rather than a stray z-index.
  3. optionsSearch merges with the defaults instead of replacing them, so setting a placeholder no longer disables the search filter.
  4. Widget-only options no longer leak into Inputs.checkbox.
  5. Notebook globals are real imports.
  6. The counter announces to screen readers; the search input has an accessible name.
  7. Returns a single <div> rather than a DocumentFragment — the notebook's return value was emptied when appended, so it could not be re-appended, styled, or measured.
  8. Assigning .value refreshes the display. The notebook updated internal state only, leaving the checkboxes stale.
  9. Typing in the search box no longer leaks an input event to consumers.
  10. Options outside data are ignored rather than inflating the counter forever — value: ["A","B","C"] on a two-option widget used to read (3 of 2 selected).

Full rationale in docs/superpowers/specs/.

Development

npm ci
npm run lint          # ESLint + Prettier
npm test              # unit tests for the search filters
npm run typecheck     # tsc over the declarations
npm run test:e2e      # Playwright, Chromium — builds dist/ first
npm run build         # rollup → dist/

Contributors and agents: read CLAUDE.md first. It documents the ten traps in this codebase — several lines look like bugs and are not — and the mandatory red→green test discipline.

License

MIT © John Alexis Guerra Gómez