Tag selector
Interests, languages, a workspace's tags: toggle chips with a limit and a count — the others rest once the limit is reached. With a marker an option is a tag with its colour; creatable adds a field where Enter takes the tag typed or creates it.
- Domain
- Forms
- Support level
- Size
- 4.9 kB gzip, budget 13.8 kB
- Who uses it
- 4 files of the live products and sites import it (Verikora: 3, Folioviv: 1) Counted in the dated inventory of 2026-11-23.
import { TagSelector } from "@krizaka/ui/tag-selector";Web and mobile — the same component for React and React Native. Beta: its API may still change in a minor version.
Why it is here. Used by Verikora, Folioviv.
When to use
- A profile's interests, up to five.
- Filters by topic with a limit.
- A workspace's tags on a file (
creatable): choose among the tags that exist, or type a new one and give it a colour of the closed palette.
When not to use
- To type free words that are not a list the workspace keeps (keywords, e-mail recipients).Use instead: Tag input
- For one choice.Use instead: Radio group
Installation
Install
npm install @krizaka/ui @krizaka/tailwind @krizaka/tokens tailwindcssStyles
@import "tailwindcss";
@import "@krizaka/tailwind";
@import "@krizaka/ui/tailwind.css";Import
import { TagSelector } from "@krizaka/ui/tag-selector";Examples
Interests
Ten interests, up to five.
A workspace's tags
creatable: type to narrow, Enter takes the tag of that name or creates one in the colour chosen; the tags carry their markers.
Props
Toggle chips with a limit and a count — the others rest once the limit is reached; creatable types a new one.
| Prop | Type | Default | Description |
|---|---|---|---|
labelrequired | string | — | The group's name (“Interests”) — passed translated. |
onValueChangerequired | (value: string[]) => void | — | Called with the tags chosen. |
optionsrequired | readonly TagOption[] | — | The tags offered. |
valuerequired | readonly string[] | — | The tags chosen. |
className | string | — | Classes merged on the root. |
countLabel | ((count: number, max: number) => string) | — | The count under the tags: (n, max) => n + " of " + max. |
creatable | boolean | — | Adds a field: Enter chooses the tag typed, or asks the host to create it. |
createLabel | ((name: string) => string) | (name) => `Create “${name}”` | The create button: (name) => "Create “" + name + "”", passed translated. |
defaultMarker | "blue" | "green" | "amber" | "red" | "violet" | "gray" | blue | The colour a new tag starts with (default blue). |
emptyLabel | string | — | What is said when nothing matches and creating is not offered (“No tag of that name”), passed translated. |
inputLabel | string | — | The field's accessible name ("Add a tag"), passed translated. |
markerLabel | string | — | The colour choice's accessible name ("Colour of the new tag"). |
markerNames | Readonly<Record<"blue" | "green" | "amber" | "red" | "violet" | "gray", string>> | — | The name of each colour, passed translated: shows the colour choice beside the field. |
max | number | — | The most that can be chosen. |
maxLength | number | 80 | The most characters of a name (default 80, the contract's NAME_MAX). |
onCreate | ((name: string, marker: "blue" | "green" | "amber" | "red" | "violet" | "gray") => void) | — | Called with the new name (trimmed, as typed) and the marker chosen; the host creates the tag (it may refuse), adds the option and chooses it. |
placeholder | string | — | The field's placeholder, passed translated. |
showMarkerNames | boolean | — | Writes each colour's name beside its swatch (MarkerPicker showNames): the colour is never only a hue. |
Accessibility
- A group named by
label; each chip says whether it is chosen; the count is announced. creatable: the field has its own accessible name (inputLabel) and controls the group; the colour choice is a named radio group.
Keyboard
| Keys | Action |
|---|---|
| Tab / Space | Reach and toggle each chip. |
| Enter | creatable: in the field, chooses the tag typed or creates it. |
| Backspace | creatable: on an empty field, takes the last chosen tag back. |
| Esc | creatable: clears the field. |
Best practices
- Say the limit in the count (“3 of 5 chosen”).
- Order the options by popularity, not alphabet.
creatable: the host creates the tag inonCreate(name, marker)(it may refuse a duplicate or a limit), adds the option and chooses it; passmarkerNamesto let the person pick the colour, andshowMarkerNamesto write each colour's name beside its swatch.- Never the only signal: a tag's colour sits beside its name.
Related components
Generated from the code of @krizaka/ui 5.3.4: its meta.ts, its examples and its types.Edit this documentation on GitHub