Tag Browser
tag-browserControlsPick keywords by category, preset-browser style.
$ pnpm dlx shadcn@latest add @pluginui/core-tag-browserInstall
Copies the source into your project. Anything it depends on comes with it. Run this in your React project with shadcn initialized; no registry configuration is needed.
Pulls in
Install using the registry URL
$ pnpm dlx shadcn@latest add https://pluginui.com/r/core-tag-browser.jsonUsage
Connect the documented props to your application or host.
import { TagBrowser } from "@/components/ui/tag-browser"
<TagBrowser
variant="panel"
search
disableZeroCount={browseMode}
categories={[
{ id: "instrument", label: "Instrument", selection: "single", tags: instruments },
{ id: "character", label: "Character", selection: { max: 3 }, tags: characters },
]}
value={selection}
onChange={(next) => setSelection(next)}
/>About Tag Browser
A controlled category/keyword chip browser. Each category is single-select (a pick replaces) or allows up to n chips (the next pick is refused and announced). Chips can show match counts; in browse mode a chip that matches nothing is disabled but stays focusable. Per-category and global clear, and an optional search. Columns from 560 px, stacked and wrapping below, so a 360 px face never scrolls sideways. Quiet, Panel and Glass skins share the headless useTagBrowser hook; the rules are a pure, tested model.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| categories | TagCategory[] | — | Each { id, label, selection?, tags }. selection is "single" or { max }; omitted means unlimited. Tags are { id, label, count?, disabled?, keywords? }. |
| value / onChange | Record<string, string[]> / (next, change) => void | — | Controlled selection: category id → chip ids in pick order. change says toggle, clear-category or clear-all. |
| disableZeroCount | boolean | false | Browse mode: chips whose count is 0 cannot be picked. Selected chips stay clearable. |
| search / query / onQueryChange | boolean / string / callback | — | Show the filter field; optionally control its text. |
| layout / columnsMinWidth | "auto" | "columns" | "stacked" / number | "auto" / 560 | Columns from the component's own width, stacked below it. |
| variant | "quiet" | "panel" | "glass" | "quiet" | The PresetSelector skins. |
Interaction
- Keyboard One tab stop. Columns: Up/Down within a category, Left/Right across. Stacked: Left/Right along the chips, Up/Down between categories. Home/End, Ctrl+Home/End. Space or Enter toggles.
- Limits A single-select category replaces its chip; a full category refuses another pick and says why in a polite live region.
- Search Type to filter chips; ArrowDown enters the chips, ArrowUp from the first row returns, Escape clears.