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

@icos-cp/multiselect

v0.1.1

Published

Searchable multi-select dropdown with tag input

Readme

ICOS Carbon Portal Multiselect widget

Description

Searchable multi-select dropdown with tag input.

Installation

npm install @icos-cp/multiselect

Requirements

  • React 18 (peer dependency).
  • Bootstrap 5 CSS is optional but recommended. The widget styles itself from --bs-* custom variables with hardcoded fallbacks, so it looks correct without Bootstrap and picks up the host theme (including dark mode) with it.
  • Font Awesome must be loaded by the host application. The caret and the tag-remove glyphs are fas fa-caret-down and fas fa-times; without Font Awesome they render as empty boxes and the remove button becomes an invisible (though still clickable) target.

Usage

import { Multiselect } from '@icos-cp/multiselect';

const [selected, setSelected] = useState([]);
const [open, setOpen] = useState(false);

<Multiselect
	data={stations}
	value={selected}
	textField="name"
	dataKey="id"
	open={open}
	onToggle={setOpen}
	onChange={setSelected}
	placeholder="Filter stations"
	inputProps={{'aria-label': 'Stations'}}
/>

open and value are both controlled — the component keeps no copy of either, so onToggle and onChange must be wired up for it to do anything.

Props

| Prop | Type | Description | |------|------|-------------| | data | T[] | The items to choose from. Selected items are removed from the list. | | value | T[] | The selected items, rendered as tags. Controlled. | | textField | keyof T | The field holding an item's label. Omit for string[]/number[], where the item is its own label. | | dataKey | keyof T | The field identifying an item. Recommended — see below. | | open | boolean | Whether the dropdown is open. Controlled. | | onToggle | (open: boolean) => void | Called when the widget wants to open or close. | | onChange | (value: T[]) => void | Called with the next selection. | | onSearch | (searchTerm: string) => void | Called as the search term changes, and with '' when it is cleared. Pair with filter={false} for external search. | | filter | false \| 'contains' \| 'startsWith' \| (item, term) => boolean | How to filter locally. Defaults to 'contains'. false disables local filtering. | | placeholder | string | Shown in the input while nothing is selected. | | className | string | Added to the root element. | | inputProps | input attributes | Forwarded to the search input. Use this to give it an accessible name. | | renderListItem | ({item, searchTerm}) => ReactNode | Custom option rendering. | | renderTagValue | ({item}) => ReactNode | Custom tag rendering. |

dataKey

Without a dataKey, items are compared by reference and keyed by their text. That means selected items won't be filtered out of the list if data is rebuilt on each render, and items sharing a label will collide as React keys. Pass a dataKey whenever the items have a stable identifier.

filter and onSearch

Local filtering runs on the data you pass in, so if onSearch triggers a fetch that matches on fields other than textField, the default 'contains' filter will hide those results. Pass filter={false} to leave filtering entirely to the caller.

Note that react-widgets' Multiselect defaults to 'startsWith'; this component defaults to 'contains', and filter="startsWith" restores the react-widgets behaviour.

Keyboard

| Key | Action | |-----|--------| | ArrowDown | Open the list, or move the highlight down | | ArrowUp | Move the highlight up; from nothing highlighted, wraps to the last item | | Home / End | Highlight the first / last item | | Enter | Select the highlighted item | | Escape | Close the list and clear the search | | Backspace | With an empty search, remove the last tag |

Tabbing out of the widget closes it and clears the search, as does clicking outside it.

Styling

The popup is rendered inline rather than in a portal, so an ancestor with overflow: hidden will clip it. Its stacking order can be retuned with the --cp-multiselect-z-index custom property (default 1005).

Open/close is a CSS animation and honours prefers-reduced-motion.

Credits

The design of this component was informed by react-widgets' Multiselect (MIT License, © 2014 Jason Quense), which it replaces as this project's multiselect dropdown.