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.
- Domaine
- Formulaires
- Niveau de support
- Taille
- 4.9 kB gzip, budget 13.8 kB
- Qui l'utilise
- 4 fichiers des produits et sites en production l'importent (Verikora : 3, Folioviv : 1) Compté dans l'inventaire daté du 2026-11-23.
import { TagSelector } from "@krizaka/ui/tag-selector";Web et mobile — le même composant pour React et React Native. Bêta : son API peut encore changer à une version mineure.
Pourquoi il est là. Used by Verikora, Folioviv.
Quand l’utiliser
- 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.
Quand ne pas l’utiliser
- To type free words that are not a list the workspace keeps (keywords, e-mail recipients).À la place : Tag input
- For one choice.À la place : Radio group
Installation
Installer
npm install @krizaka/ui @krizaka/tailwind @krizaka/tokens tailwindcssStyles
@import "tailwindcss";
@import "@krizaka/tailwind";
@import "@krizaka/ui/tailwind.css";Importer
import { TagSelector } from "@krizaka/ui/tag-selector";Exemples
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 | Défaut | Description |
|---|---|---|---|
labelrequis | string | — | The group's name (“Interests”) — passed translated. |
onValueChangerequis | (value: string[]) => void | — | Called with the tags chosen. |
optionsrequis | readonly TagOption[] | — | The tags offered. |
valuerequis | 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. |
Accessibilité
- 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.
Clavier
| Touches | 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. |
Bonnes pratiques
- 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.
Composants liés
Générée depuis le code de @krizaka/ui 5.3.4 : son meta.ts, ses exemples et ses types.Modifier cette documentation sur GitHub