Skip to Content
Cristal

Forms

Tags

Keyword input turned into chips.

<cr-tag-input>CrTagInput

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; with required, at least one tag is needed.

API

Properties

PropertyTypeDefaultDescription
disabledbooleanfalseDésactive le champ.
errorstring—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.
hintstring—Texte d'aide, lu par les lecteurs d'écran.
label (obligatoire)string—Libellé affiché au-dessus du champ.
namestring—Nom envoyé avec le formulaire, une fois par étiquette.
placeholderstring—Texte indicatif affiché quand le champ est vide.
requiredbooleanfalseDemande au moins une étiquette.
valuesstring[][]Étiquettes saisies.

Events

Reactevent.detailDescription
onCrChangestring[]Émis quand la liste change ; detail : les étiquettes.

CSS parts

To style it from outside: cr-tag-input::part(name) { … }

PartDescription
labelLe libellé.
tagUne étiquette.

On this page