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

@webfactoryde/cascading-select

v0.1.4

Published

Web Component for interdependent select form elements, where the available options in a dependent selection list are based on the selection in a parent or control list.

Readme

Web Component for interdependent <select> form elements, where the available options in a dependent selection list are based on the selection in a parent or control list. This pattern is also known as "dependent select" (a subform of the generic "input-dependent input") or "cascading dropdowns".

Installation

npm install @webfactoryde/cascading-select

Usage

The <cascading-select> Web Component is a lightweight wrapper for standard form markup. If offers complete flexibility in regard to the use of <fieldset>, <legend>, <label> and other elements or attributes (i. e. class) needed for layout and styling, as long as two <select> elements with the necessary (data-) attributes are present.

The second, dependent <select> should initially be hidden (via a hidden attribute). This way, in case there are JavaScript errors, the parent <select> does still offer high-level filtering and only the progressive enhancement of the secondary filter level is missing.

Steps to implement:

  1. The JS file "cascading-select.js" must be loaded. Depending on browser support requirements, transpilation for older browsers is recommended.
  2. Two <select> elements must be output within the Web Component.
  3. The parent <select> requires a data-dependent-id attribute that contains the id of the dependent <select> as its value to link the two fields.
  4. The <option>s of the parent <select> that have a sub-selection at the second level require a data-dependent-options attribute with a JSON-formatted array of objects, each containing a label and value. Empty placeholder options must also be listed.
  5. The dependent <select> requires an id attribute with matches the value used for data-dependent-id on the parent.
  6. The dependent <select> should initially have a hidden attribute; this will be removed by the Web Component as needed, but serves as a no-JS fallback in case the Web Component does not initialize correctly.

Parameters

Web Components support common HTML attributes but can also receive custom parameters.

| Option | Type | Default | Description| |-----------------------|---------|---------|-----------| | always-show-dependent | boolean | false | Controls initial display of the second ("dependent") <select> when no selection is made in the first ("parent") or an option without sub-selection possibilities is selected. Default: the second field is hidden. When the parameter is present, it is displayed and marked with aria-disabled (assuming it has no meaningful interactivity until a selection is made in the "parent", but should still be visible to visually indicate the functional pattern).|

Example

<cascading-select>
    <fieldset>
        <legend>Where do you want to go bouldering?</legend>
        <div>
            <label for="town">City</label>
            <select id="town" name="town" data-dependent-id="gym">
                <option value="">Please choose a city</option>
                <option
                    value="1"
                    data-dependent-options='[
                        { "value": "", "label": "Please choose a gym" },
                        { "value": "d11", "label": "Boulders Habitat Bonn" },
                        { "value": "d12", "label": "Boulders Habitat Beuel" }
                    ]'
                >
                    Bonn
                </option>
                <option
                    value="2"
                    data-dependent-options='[
                        { "value": "", "label": "Please choose a gym" },
                        { "value": "d21", "label": "Boulderplanet" },
                        { "value": "d22", "label": "Stuntwerk Köln" },
                        { "value": "d23", "label": "Kletterfabrik" },
                        { "value": "d24", "label": "K11" }
                    ]'
                >
                    Köln
                </option>
                <option
                    value="3"
                    data-dependent-options='[
                        { "value": "", "label": "Please choose a gym" },
                        { "value": "d31", "label": "Monolith" },
                        { "value": "d32", "label": "Boulderfactory" },
                        { "value": "d33", "label": "KletterBar" }
                    ]'
                >
                    Münster
                </option>
            </select>
        </div>
        <div>
            <label for="gym">Gym</label>
            <select id="gym" class="form-control"></select>
        </div>
    </fieldset>
</cascading-select>