Skip to content

Chip Input ​

The catnip-input-chip custom element collects multiple string values (tags, filters, skills, etc.): a single-line draft field, Add control (on by default), and removable chips below. It composes catnip-input internally for the draft line so sizing, intent, icons, and label patterns stay aligned with Input. Shared label and supporting-text behaviour is summarised on Inputs overview.

Overview ​

  • Chips (v-model): model-value / .modelValue is the committed chips (string[]). Draft typing is not part of modelValue.
  • Commit: Non-empty draft commits on Enter (default input only) or via Add. Set show-add-button="false" for Enter-only. Emits update:modelValue with the new chips array.
  • Chip limits: Use min-chips / max-chips to keep the committed tag count within bounds. Use max-visible-chips to show only the first tags and collapse the rest behind a tertiary Show n more control, then expand/collapse with Show more / Show less.
  • Add button: Forward props through .addButton="{ label, buttonAriaLabel, appearance, leftIcon, ... }". label overrides the default + Add string (inputChip.add in the bundled locale); type, disabled, and size stay the chip input.
  • Draft input props: Configure the default embedded text field with .catnipInput="{ placeholder, leftIcon, showClearButton }". Ignored when the draftInput slot is used.
  • Clear draft (default input): Set catnipInput.showClearButton to show catnip-input’s trailing clear control while the draft has text. It clears only the unsent line, not chips (catnipInput.clearButtonAriaLabel overrides the default input.clear label).

Draft line ​

Two ways to supply the draft field — pick one; the draft API differs:

Default embedded catnip-inputdraftInput slot
Set draft from parentchipRef.setDraftValue('…').draftValue="draft"
Observe draft@update:draftValue (optional)Your slotted control binding
After Add commitsChip clears draftYou clear .draftValue

Default — chip owns draft; parent intervenes with setDraftValue() when needed (prefill, reset). Do not bind .draftValue.

Custom slot — parent owns draft entirely via .draftValue. Do not call setDraftValue() (no effect). See Chip Input — Specs — Draft line.

Live example ​

Relationship to catnip-input ​

There is no type="chip" on catnip-input. Use this component whenever you need chips. Shared behaviour (label slots, supporting text, intents, leading icon) matches Input; draft-specific input props are forwarded through catnipInput following the composed components convention.

Guidelines ​

Use catnip-input-chip when users need to add and remove multiple short string values (tags, filters, skills). For plain text, email, password, or textarea fields, use Input instead.

Behaviour ​

  • State: Bind model-value / .modelValue (string[]) for committed chips.
  • Draft (default input): Chip owns draft internally. Parent sets via setDraftValue() on a host ref (prefill, reset). Parent observes via optional @update:draftValue. Binding .draftValue has no effect on the default input.
  • Draft (draftInput slot): Parent binds .draftValue and wires the slotted control to the same ref. setDraftValue() does nothing — use the prop. Clear .draftValue after commit in @update:modelValue.
  • Committing a tag: Non-empty draft commits on Enter or via Add (shown by default). Set show-add-button="false" if you want Enter-only. The component emits update:modelValue with the new array. It does not emit per-tag events; add/remove are reflected only in that array.
  • Tag limits: Set min-chips to prevent removing below the minimum committed count and max-chips to prevent adding beyond the maximum. These props constrain user actions; keep app-level validation messages in your form flow.
  • Visible tags: Set max-visible-chips when long chip lists would crowd the field. Hidden chips are represented by a tertiary Show n more button; the expanded list shows Show less at the bottom-right. Override labels with show-more-chips-label / show-less-chips-label if needed.
  • Add button: Shown by default; set show-add-button="false" to hide it (aligned to field size s / m / l when visible). Configure it with .addButton="{ label, buttonAriaLabel, appearance, leftIcon, ... }" — same forwarding pattern as catnipInput. label overrides the bundled inputChip.add string (e.g. + Add); set buttonAriaLabel only if the visible label is not enough for assistive tech.
  • Clear draft: Turn on catnipInput.showClearButton to show catnip-input’s clear control when the draft has text (default off). Activating it clears only the draft line, not the chips. catnipInput.clearButtonAriaLabel overrides the default input.clear string if needed. Use show-add-button for committing tags; reserve clear for wiping the unsent line.
  • Forms: The custom element’s form value is a comma-separated list of tags; draft text is not submitted.

Layout ​

Chips render below the draft row so the text field stays at a stable vertical position while the list grows; helper/error copy (supporting-text) sits after the chip list so long tag lists do not push the message away from the label.

Composition (shared with Input) ​

  • Labels: Use the label prop or label slot; optional label.action / label.suffix slots match Input. For custom controls, use Field Label standalone. See Input — Guidelines.
  • Supporting text: Pass supporting-text—do not mount <catnip-field-supporting-text> manually. On catnip-input-chip, helper text is rendered after the chip list and still describes the draft control.
  • Draft input (default): Put draft-only input props under catnipInput. To prefill or reset draft from the parent, call setDraftValue() on a host ref — not .draftValue. Listen to @update:draftValue only if you need to mirror draft state elsewhere.
  • Draft input (custom): Use slot="draftInput" when the default catnip-input is not enough. Bind .draftValue; wire your slotted control to that ref. Add commits draftValue; parent clears draft in @update:modelValue. Enter, focus, and validation on the slotted control are the parent's responsibility.

Intents and status ​

The intent prop matches Input: neutral, warning, danger (sets aria-invalid on the draft control), success. See Input — Guidelines — Intents and Status.

Best practices ​

  • Prefer Enter and/or the Add button over ambiguous icons for “commit tag”.
  • Keep chip lists manageable with max-visible-chips when users can accumulate many tags.
  • Default vs custom draft: use setDraftValue() with the embedded input; use .draftValue with the draftInput slot — not both for the same field.

Catnip Design System by Signicat