Forms
Tags
Keyword input turned into chips.
Example
Each word confirmed with Enter or a comma jumps into a chip; × removes it, and Backspace in the empty field removes the last one. Pasted text with commas ("ui, motion, design") gives several chips; a duplicate is rejected. values reads and sets the list, onCrChange gives it on every change.
import { CrTagInput } from '@cristal-ui/react';
export default function TagsBasic() {
return <CrTagInput label="Topics" name="topics" placeholder="design, animation…" values={['design', 'animation']} style={{ width: '100%', maxWidth: 420 }} />;
}error-animation animates the error when it appears and on every rejected submit (zigzag, badge, echo…): see Animated error.
Accessibility
- The chips form a named list; each × is a "Remove design" button.
- Every addition or removal is announced: "ui added. 3 tags.".
- The form receives one value per tag under the same
name; withrequired, at least one tag is needed.
API
Properties
| Property | Type | Default | Description |
|---|---|---|---|
disabled | boolean | false | Désactive le champ. |
error | string | — | Message d'erreur ; remplace le message automatique. |
errorAnimation | "drop" | "echo" | "jitter" | "none" | "pop" | "wobble" | "zigzag" | 'none' | Animation de l'erreur quand elle apparaît et à chaque envoi refusé : none (par défaut), zigzag, pop, drop, echo, jitter ou wobble. |
hint | string | — | Texte d'aide, lu par les lecteurs d'écran. |
label (obligatoire) | string | — | Libellé affiché au-dessus du champ. |
name | string | — | Nom envoyé avec le formulaire, une fois par étiquette. |
placeholder | string | — | Texte indicatif affiché quand le champ est vide. |
required | boolean | false | Demande au moins une étiquette. |
values | string[] | [] | Étiquettes saisies. |
Events
| React | event.detail | Description |
|---|---|---|
onCrChange | string[] | Émis quand la liste change ; detail : les étiquettes. |
CSS parts
To style it from outside: cr-tag-input::part(name) { … }
| Part | Description |
|---|---|
label | Le libellé. |
tag | Une étiquette. |