Talisman LogoTalisman Logo Design System
Browse documentation
Components

Textarea chips

A text field that turns typed or pasted entries into dismissible chips, for lists of identifiers such as process numbers.

Stableimport { TextareaChips } from "@repo/ui/textarea-chips";Source

Separe por vírgula, espaço ou Enter.

chipSize
variant
<TextareaChips chipSize="sm" description="Separe por vírgula, espaço ou Enter." label="Números dos processos" placeholder="Cole ou digite os números dos processos" />

Try typing a number and pressing Enter, comma or space, or pasting a list.

When to use

  • To collect many short values at once, such as process numbers in a batch.
  • When users paste lists from a spreadsheet or an e-mail.
  • When each value must be validated and removable on its own.

When not to use

  • A single value. Use Input.
  • Free-form text. Use Textarea.
  • Choosing from known options. Use Combobox or Multi select.

Examples

Validating each value

validateChip returns the sanitized value or null to reject it. Rejected and duplicate values go to onChipsRejected. Because that callback also clears the typed text, always tell the user why the values were dropped.

Separe por vírgula, espaço ou Enter.

Values with spaces

By default, comma, space and Enter create chips. Company names contain spaces, so pass separators and onTextSeparation to split only on comma and line break.

Separe por vírgula ou Enter.

Limiting the height

maxRows caps the height, and the field scrolls once it is reached.

Máximo de 2 linhas visíveis.

States

Limite de 3 processos por lote.

  • Error: pass error with the message. The border turns critical and the message replaces the description.
  • Disabled: typing and chip removal stop, and the field is dimmed.

Content

  • Label with what the values are: “Números dos processos”, “Reclamadas”.
  • Use description for the separators and the limit: “Separe por vírgula, espaço ou Enter.”
  • Write errors as the rule: “Limite de 3 processos por lote.”

Accessibility

  • The typing field is a native <input type="text">. It is named by label or, without one, by the placeholder through aria-label.
  • Backspace on an empty field removes the last chip. Enter, comma and space commit the text.
  • Each chip has a dismiss button of 24px with a visible focus ring. All of them are named “Remover”, with no reference to the chip they remove.
  • The error and description are plain text below the field and are not connected with aria-describedby.
  • Clicking anywhere in the container focuses the input.

Code

import { TextareaChips } from "@repo/ui/textarea-chips";

const [values, setValues] = useState<string[]>([]);

<TextareaChips
  label="Números dos processos"
  onChipsAdd={(newChips) => setValues((prev) => [...prev, ...newChips])}
  onChipsRejected={(rejected) =>
    setError(`Formato inválido: ${rejected.join(", ")}`)
  }
  onRemoveChip={(_value, index) =>
    setValues((prev) => prev.filter((_, i) => i !== index))
  }
  validateChip={(value) => (CNJ_PATTERN.test(value) ? value : null)}
  values={values}
/>;

Props

PropTypeDefaultDescription
chipSize"sm" | "md"smSize of each chip
descriptionstring—Helper text below the field. Replaced by `error` when set
disabledbooleanfalseDisables typing and chip removal
errorstring—Error message below the field. Also switches the border to the error style
labelstring—Label above the field, also used as the input name
maxRowsnumber—Maximum number of chip rows before the field scrolls. No limit by default
minRowsnumber5Minimum number of visible rows
onChipsAdd(newChips: string[]) => void—Called with the validated, de-duplicated values to add
onChipsRejected(rejectedValues: string[]) => void—Called with the values dropped by `validateChip` or already present. Providing it also clears the typed text, so tell the user why
onRemoveChip(value: string, index: number) => void—Called when a chip is dismissed
onTextSeparation(rawValue: string) => string[]—Splits raw text into chip candidates. Overrides the default split on comma, space and line break
placeholderstring"Digite valores separados por vírgula..."Text shown while there are no chips
placeholderWithChipsstring"Adicionar mais..."Text shown once there is at least one chip
separatorsSet<string>new Set([",", " ", "Enter"])Keys that commit the typed text as a chip
validateChip(value: string) => string | null | undefined—Returns the sanitized value, or null to reject it. Runs before a chip is added
valuesstring[]—Current chip values
variant"default" | "disabled" | "error"defaultVisual state. `error` and `disabled` are derived from props

Known issues

Issue Effect
The default placeholders “Digite valores separados por vírgula…” and “Adicionar mais…” are Portuguese defaults in the package. Apps must override both props to translate them.
Chips render Chip without dismissLabel, so every dismiss button is named “Remover”. Screen reader users hear the same name for every chip and cannot tell which one they remove.
The error and description have no id and the input has no aria-describedby. Assistive technology does not read them with the field.
Edit this page on GitHub