Krizaka UI
Krizaka UI
ComposantsFormulaires

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.

Web · ✓Mobile · ✓Bureau · ✓BêtaFormulaires
Niveau de support
Bêta
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 tailwindcss

Styles

@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.

PropTypeDéfautDescription
labelrequisstring—The group's name (“Interests”) — passed translated.
onValueChangerequis(value: string[]) => void—Called with the tags chosen.
optionsrequisreadonly TagOption[]—The tags offered.
valuerequisreadonly string[]—The tags chosen.
classNamestring—Classes merged on the root.
countLabel((count: number, max: number) => string)—The count under the tags: (n, max) => n + " of " + max.
creatableboolean—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"blueThe colour a new tag starts with (default blue).
emptyLabelstring—What is said when nothing matches and creating is not offered (“No tag of that name”), passed translated.
inputLabelstring—The field's accessible name ("Add a tag"), passed translated.
markerLabelstring—The colour choice's accessible name ("Colour of the new tag").
markerNamesReadonly<Record<"blue" | "green" | "amber" | "red" | "violet" | "gray", string>>—The name of each colour, passed translated: shows the colour choice beside the field.
maxnumber—The most that can be chosen.
maxLengthnumber80The 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.
placeholderstring—The field's placeholder, passed translated.
showMarkerNamesboolean—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

TouchesAction
Tab / SpaceReach and toggle each chip.
Entercreatable: in the field, chooses the tag typed or creates it.
Backspacecreatable: on an empty field, takes the last chosen tag back.
Esccreatable: 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 in onCreate(name, marker) (it may refuse a duplicate or a limit), adds the option and chooses it; pass markerNames to let the person pick the colour, and showMarkerNames to write each colour's name beside its swatch.
  • Never the only signal: a tag's colour sits beside its name.

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

Sur cette page