Skip to content
IndexRequest a UIAboutContact

Tag Input with Chips

Type a word and press Enter to make a chip; Backspace removes the last chip and duplicates are rejected.

Open alone ↗

AI prompt

PROMPT: PASTE INTO YOUR AI CODING TOOL
Create a tag input field that holds up to five tags. Typing text and pressing Enter or comma adds a rounded chip with the text and a small X button; Backspace on an empty input removes the last chip; clicking X removes that chip; pasting "design, motion, ui" creates three chips. Duplicate tags are rejected with the inline message "Already added", and at five tags the input is disabled with "Limit reached (5)". Show a live counter "2 of 5". The field looks like a normal text input (1 pixel border, 10 pixel radius) with chips wrapping inside; focus shows a 2 pixel outline. Chips have aria-labels "Remove design", messages use aria-live polite. 150 millisecond scale-in with prefers-reduced-motion fallback. Plain HTML, CSS and JavaScript.

About this pattern

Definition

A tag input turns typed words into removable chips inside one field. It collects several short values, such as keywords or recipients, without a separate list control.

Purpose & UX principles

  • Use for tags, keywords, emails and skills where users add several short items.
  • Add on Enter or comma, remove with Backspace on empty input or the chip's X; support paste of comma-separated lists.
  • Validate gently: reject duplicates and over-limit with a short inline message and keep focus.

Interaction states

  • Empty with placeholder, with chips, focused, at limit (5 tags), duplicate warning.

Motion specification

  • A new chip scales in from 0.8 over 150ms; removed chips fade over 120ms.
  • Reduced motion: chips appear and disappear instantly.

Responsive behaviour

  • Chips wrap onto new lines inside the field; the input keeps a minimum width of 80px.
  • Chip remove buttons must be at least 24px for touch.

Code

HTML
<div class="bx"><label for="in" class="lb">Keywords</label><div class="fld" id="fld"><input id="in" placeholder="Add a keyword…" autocomplete="off"></div><div class="meta"><span id="msg" aria-live="polite"></span><span id="cnt">0 of 5</span></div></div>

Related patterns

Text Input

↗
Text InputInputs & Forms

Validation States

↗
Validation StatesInputs & Forms

Search Input

↗
Search InputInputs & Forms