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

@htmlbricks/hb-input-checkbox

v0.76.5

Published

Checkbox or Bulma-styled switch. Optional `params` as `InputCheckboxParams`: `type` may be `"switch"` for the switch UI, otherwise a standard checkbox. `schemaentry.label` drives the visible label and required asterisk; boolean `value` is parsed from JSON

Downloads

2,543

Readme

hb-input-checkbox

Category: inputs · Tags: inputs

Summary

Labeled checkbox or Bulma switch (params.type === "switch") from schemaentry. Emits setVal on checked/validity changes. Missing or invalid schemaentry → nothing rendered.

schemaentry is typed as optional string | FormSchemaEntry for HTML vs JS; the control appears once a valid field is parsed.

Custom element

<hb-input-checkbox></hb-input-checkbox>

Tag name: hb-input-checkbox

Attributes (host)

Web component attributes use snake_case. Values exposed through HTML attributes are strings (including JSON for structured data and yes / no for booleans where noted).

| Attribute | Required | Description | |-----------|----------|-------------| | schemaentry | Yes (for visible UI) | JSON string (HTML) or object (JS). Must include a string id when parsed. See Schema (schemaentry) below. | | show_validation | No | yes or no (default no). When yes, a required but unchecked field shows validationTip inside the shadow tree and the host gets an invalid outline. | | id | No | Optional id on the custom element host. | | style | No | Optional inline styles on the host element. |

Schema (schemaentry)

The TypeScript shape is built from shared form row fields plus checkbox-specific params. At minimum, provide id. Other keys are optional unless you need labels, defaults, or validation UX.

| Key | Description | |-----|-------------| | id | Stable field identifier. Used in setVal payloads and as the native control id. | | label | Text beside the control. A * is appended when required is true. | | required | When true, valid is false until the control is checked. | | value | Initial / synced value: boolean, number, or string (coerced to boolean with JavaScript truthiness when applied). | | validationTip | Message shown when show_validation is yes, required is true, and the box is unchecked. | | disabled | When true, the input is disabled and not interactive. | | readonly | When true, the input is disabled for interaction (same net effect as disabled for the native control). | | placeholder | Allowed by the shared schema; this checkbox implementation does not render a separate placeholder control. | | params | See Switch mode (params.type). |

Switch mode (params.type)

Optional params object:

| Key | Values | Description | |-----|--------|-------------| | type | "switch" (or omit / other for default) | When "switch", the native checkbox is styled as a Bulma-colored switch (track and knob). Otherwise a standard checkbox appearance is used. |

TypeScript

types/webcomponent.type.d.tsInputCheckboxParams, FormSchemaEntry, Component, Events.

Validation and events

Validity: If required is true, valid is true only when the control is checked. If required is false or omitted, valid is always true.

setVal custom event: Fired when value, valid, or the field id changes, after internal de-duplication of identical payloads.

| Property | Type | Description | |----------|------|-------------| | detail.value | boolean | Current checked state. | | detail.valid | boolean | Whether the field satisfies required. | | detail.id | string | The schemaentry.id. |

Listen in HTML or script:

<hb-input-checkbox id="terms"></hb-input-checkbox>
<script>
  document.getElementById("terms").addEventListener("setVal", (e) => {
    console.log(e.detail); // { value, valid, id }
  });
</script>

Styling

Styles use Bulma 1.x Sass inside the shadow root. The bundle forwards Bulma form layers form/shared, form/input-textarea, form/checkbox-radio, and form/tools, then applies the light theme on :host (see styles/bulma.scss). Component-specific layout and switch visuals are in styles/webcomponent.scss.

Theme the host with Bulma CSS variables (see Bulma: CSS variables).

Documented --bulma-* tokens for this package (from extra/docs.ts / styleSetup.vars):

| Variable | Role | |----------|------| | --bulma-text | Label text next to the checkbox or switch. | | --bulma-border | Checkbox border and switch track border. | | --bulma-link | Switch “on” fill and border when params.type is "switch". | | --bulma-danger | Invalid outline and danger help text when validation is shown. | | --bulma-radius | Corner radius for the switch track area. | | --bulma-radius-rounded | Pill radius for the circular switch knob. |

Switch styling also reads optional greys / scheme variables (for example --bulma-grey-*, --bulma-scheme-*, --bulma-white, --bulma-input-*) as fallbacks in styles/webcomponent.scss.

CSS parts (::part)

| Part | Description | |------|-------------| | input | The native checkbox input (standard mode) or the same element styled as the switch track and knob (switch mode). | | invalid-feedback | The p.help.is-danger paragraph when show_validation is yes and the required field is invalid. |

Slots

None.

Examples

Required agreement checkbox

<hb-input-checkbox
  schemaentry='{"id":"accept","label":"I agree to the terms","required":true,"validationTip":"You must accept to continue."}'
  show_validation="yes"
></hb-input-checkbox>

Pre-checked optional subscription

<hb-input-checkbox
  schemaentry='{"id":"newsletter","label":"Email me updates","required":false,"value":true}'
></hb-input-checkbox>

Switch UI

<hb-input-checkbox
  schemaentry='{"id":"notifications","label":"Enable notifications","params":{"type":"switch"},"value":false}'
></hb-input-checkbox>

Disabled / locked state

<hb-input-checkbox
  schemaentry='{"id":"locked","label":"Terms accepted","value":true,"disabled":true}'
></hb-input-checkbox>

Package metadata

  • npm scope / repo name: @htmlbricks/hb-input-checkbox (see extra/docs.ts)
  • License: Apache-2.0 (see extra/docs.tslicenses)