Skip to content

Tag Input with Removable Chips

Tailwind CSS tag input that turns typed words into removable chips, with Enter and comma support, paste splitting, a tag limit and suggestions.

Also known as: tags input field, chip input, keyword tag input, multi value text input, tagging input

Tailwind CSS Inputs Responsive #accessible #chips #form #input #tags

Tag Input with Removable Chips live demo

Open in new tab

Tailwind CSS code (HTML, CSS, JS)

A tag input built with Tailwind CSS and vanilla JavaScript that turns typed words into removable chips. It is shown as the "Topics" field of an article form, but works just as well for skills, labels or keywords.

How it works

The root is the form.tti-tags. Inside, [data-tti-box] looks like one text field: it holds the chip list ul[data-tti-list] and the real text input [data-tti-input]. Each chip is an li.tti-chip with a data-tti-tag value and a small remove button marked data-tti-remove. Thanks to focus-within utilities the whole box gets a violet ring while typing.

The script listens for keydown on the input. Enter or a comma normalizes the text (trimmed, lowercased, spaces turned into hyphens, 24 characters max) and adds a chip. Pasting a comma-separated list adds every part at once. Backspace in an empty field first marks the last chip with tti-chip--armed and removes it on the second press, so a single keystroke never deletes a tag by accident; Escape cancels. Duplicates and going over the limit are rejected: the box gets the tti-box--shake class and a message appears in [data-tti-message].

The suggestion buttons (data-tti-suggest) add their tag in one click and are disabled once that tag is present. After every change the script updates the 3 / 8 counter in [data-tti-count] and writes a comma-separated list into the hidden input[name="topics"] ([data-tti-value]), so the field submits like any other form control. The submit handler calls preventDefault() and simulates saving with a short timeout; replace that timeout with a fetch() call to send the value to your API.

Customization

  • data-tti-max on .tti-tags: change the maximum number of tags; the counter, placeholder and suggestions follow automatically.
  • normalize() in script.js: remove the .toLowerCase() call or change the allowed characters if your tags are case-sensitive.
  • maxlength="24" on [data-tti-input] and .slice(0, 24) in normalize(): allow longer tag names.
  • CHIP_CLASS in script.js and the matching classes on the initial chips: swap bg-violet-600 for another color or use rounded-md for square tags.
  • .tti-chip--armed in style.css: change the highlight color of a chip that is about to be removed.
  • data-tti-suggest buttons: replace them with your most-used tags, or delete the whole suggestions block.

Use cases

  • Blog and CMS editors: authors add topics to an article by typing and pressing Enter or comma
  • Profile forms: collect skills as removable chips with a limit and a counter
  • Content tools: pasting a comma-separated list adds all keywords at once
  • Admin forms: clickable suggestions add common tags and are disabled once used
  • Filtering interfaces: tags are stored in a hidden field so the form submits like any other input

Accessibility

The text input has a real label and is described by the keyboard hint and the error message through aria-describedby. Chips are list items inside a labeled list, and every remove button has an aria-label such as "Remove css". After removing a chip with its button, focus moves to the next chip's remove button or back to the input. Additions and removals are announced in a visually hidden aria-live region together with the new count, and the save result appears in a role="status" element. All buttons show a visible focus ring, and the pop and shake animations are disabled under prefers-reduced-motion.

Usage notes

For several tag inputs on one page, give each input and its hint and message elements unique id values.

Tag Input with Removable Chips at a glance

Framework
Tailwind CSS
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
Tailwind CSS
Layout
Responsive, works on mobile
Category
Inputs
License
Free for personal and commercial use

Questions about this template

Can I use the Tag Input with Removable Chips code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

Load Tailwind CSS from a CDN (the links are under Requirements). Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

Add these to your page (already included in the download):

  • <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>

The Tailwind browser build is for prototyping. In production, compile Tailwind with its CLI or your bundler.

Tag Input with Removable Chips – Tailwind CSS inputs component screenshot
Tag Input with Removable Chips · Tailwind CSS Inputs

More Inputs

Password Strength Meter – Bootstrap 5 inputs preview

Password Strength Meter

Bootstrap 5 password input with show/hide toggle, four-step strength meter, live requirements checklist and confirmation match check.

Inputs with Icons and Add-ons – Tailwind CSS inputs preview

Inputs with Icons and Add-ons

Tailwind CSS input group examples with leading icons, text prefixes and suffixes, a currency select, password toggle, clear button and helper text.

OTP Code Input Boxes – Tailwind CSS inputs preview

OTP Code Input Boxes

Six-digit Tailwind CSS OTP verification input with auto-advance, paste support, backspace navigation, resend timer and simulated check.

Floating Label Inputs – Bootstrap 5 inputs preview

Floating Label Inputs

Bootstrap 5 floating label inputs for text, email, select and textarea, styled as filled fields with validation, read-only and disabled states.