Input chips

A text field that turns what is typed into removable chips: tags, keywords or e-mail recipients. Its value is the list of entries.

  • vig-input-chips
Import
import { InputChips } from '@vigdx/ui/input-chips';

Basic

Enter or a comma turns the text into a chip; [(value)] holds the entries as a string[] . Entries are trimmed and a duplicate stays in the field as typed, with a message ( allowDuplicates accepts it; entryKey decides what counts as the same entry, by default the text in Unicode NFC). Only the entry a typed separator ends is added; the rest of the field is left as it is. Backspace in the empty field steps onto the last chip, the arrow keys move between chips, and Backspace or Delete removes the focused one.

Value: [ "angular", "signals" ]

Separators, limits and validation

separators lists the characters that end an entry as it is typed or pasted (a comma by default); a paste of several lines adds each line. maxLength stops at a count, validator returns true , false or a message, and addOnBlur adds the text when focus leaves. Rejected entries stay in the field and the message shows under it.

Up to five addresses; paste a list to add them all.

Signal Forms

Bind an array field with [formField] . Counts are minLength and maxLength on the array; a schema's maxLength also binds the field's own, so further entries are refused as they are typed.

Two to four keywords.

Reactive Forms

Import VigValueAccessor next to the field for formControlName , formControl and ngModel . A reset writes [] and drops the typed text.

{
  "skills": []
}

Styling hooks

Internal elements carry a stable data-part and the component's data-scope; both are public API, so removing one is a breaking change. Select a part by both, e.g. [data-scope="input-chips"][data-part="field"] { … }: the pair stays within this component when kit components nest, and also reaches parts in overlay panels, which render outside the host. State is exposed through aria-* and, where listed, a data-state; literal values are checked by the API gate, values computed from the component's state follow its documented types. Other data-* attributes listed below (such as data-opening while an overlay animates) are API too. See Customizing.

Scope: [data-scope="input-chips"]

InputChips styling hooks
Part Element data-state
field Positioned wrapper of the label, the box and the clear button. —
label The visible (or floating) <label> . —
control The bordered box holding the chips and the text field. —
chip A vig-chip per entry; style its own parts ( data-scope="chip" ). —
input The native text <input> . —
clear The clear button ( clearable ). —
status The visually hidden role="status" region announcing changes. —
hint The vig-hint (a display: contents host; style its text part). —
disabled-reason The vig-hint with the disabled reason ( display: contents ). —
error The vig-field-error (a display: contents host; style its message part). —

Accessibility

  • The field is a native text input with a <label>; it is described by the entries (read after its name), the hint and the error. Each chip is a vig-chip whose remove button is named "Remove" and the entry.
  • Additions, removals and rejections are announced through a polite status region (one message for a paste of several entries).
  • Typing with an input method (Japanese, Chinese, Korean…) is never split or committed while a composition is open: Enter confirms the composition, not the entry.
  • The field is the only Tab stop: Backspace in the empty field, or the arrow keys at its start (mirrored in right-to-left pages), move onto the chips' remove buttons, and the arrow keys, Home and End move between them. Removing with a key moves on to the next chip; removing with the pointer keeps focus in the field.
  • Texts are translated with the locale or per instance through labels (removeAriaLabel, clearAriaLabel, the announcements and the duplicate, limit and invalid messages).

API

InputChips

vig-input-chips component

A text field that turns what is typed into removable chips, for tags, e-mail recipients or keywords. Enter, a separators character (a comma by default) or a paste of several lines adds entries; Backspace in the empty field steps onto the last chip, and the arrow keys move between chips, where Backspace or Delete removes one. The value is the entries, in order.

Example :
<vig-input-chips label="Tags" [formField]="form.tags" />

Entries are trimmed; duplicates, entries past maxLength and entries the validator rejects stay in the field with a message. Typing with an IME is never split mid-composition. Additions and removals are announced politely. Works with Signal Forms and, through VigValueAccessor, with Reactive Forms and ngModel. A schema's maxLength stops further entries; minLength and required validate the array as usual.

InputChips props
Name Type Default Description
addOnBlurbooleanfalse

Leaving the field adds what was typed (when it is accepted).

allowDuplicatesbooleanfalse

Accepts an entry that is already a chip (compared by entryKey).

clearablebooleanfalse

Shows a button that removes every chip.

dirtybooleanfalse
—
disabledbooleanfalse
—
disabledReasonsreadonly WithOptionalFieldTree<DisabledReason>[][]
—
entryKey(entry: string) => stringnfc

What makes two entries the same for the duplicate check, e.g. (entry) => entry.toLocaleLowerCase(). By default the trimmed text in Unicode NFC, so "é" typed or pasted in either form is one entry.

errorMessagesRecord<string, string>—
—
errorsreadonly ValidationError.WithOptionalFieldTree[][]
—
hiddenbooleanfalse
—
hideLabelbooleanfalse

Visually hides the label, which still names the field; pair it with a placeholder.

hintstring | undefinedundefined
—
invalidbooleanfalse
—
label required string—
—
labelPositionLabelPosition'float'

float (default) rests the label inside the field; top sets it above.

labelsPartial<InputChipsLabels>—

Texts (i18n); locale defaults.

maxLengthnumber | undefinedundefined

At most this many entries; further ones stay in the field with a message. The Signal Forms name of the array's length limit, so a schema's maxLength(path, n) binds it.

namestring''
—
pendingbooleanfalse
—
placeholderstring | undefinedundefined

Shown in the empty field while there are no chips.

readonlybooleanfalse
—
requiredbooleanfalse
—
separatorsreadonly string[][',']

Characters that end an entry as it is typed or pasted, besides Enter.

sizeFieldSize'md'
—
touchedbooleanfalse
—
validatorInputChipsValidator | undefinedundefined

Checks each entry before it becomes a chip; see InputChipsValidator.

value model string[][]

The entries, in order; [] when empty.

Are you sure?