
The elastic button
Buttons, Hover, Text
The tag field of a form: type a word and Enter closes it into a pill on a spring. Below, the suggestions starting with what you are typing light up and one tap adds them. Backspace on an empty field first marks the last tag, then removes it. Five at most: at the sixth the field says no with a shake.
A folder that runs on its own: index.html, style.css, script.js and the libraries from a CDN. The React and Vue tabs hold the same demo as a ready component, which switches its animations off when it leaves the page.
<!doctype html>
<!--
"Tags input field" from Animorio · https://animorio.com
License: free on your own sites and your clients’ sites, paid work included.
Not for resale, redistribution, templates or code collections · https://animorio.com/en/license/
-->
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Tag field with words that close into pills and suggestions</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/wdth.css">
<link rel="stylesheet" href="style.css">
</head>
<body>
<main class="stage">
<!-- the tag field of a publishing form: you type a word and Enter closes it into a pill on a spring; under the
field the suggestions that match what you are typing light up and one tap adds them; Backspace on an empty
field first marks the last tag, then removes it; five tags at most, and the field says no with a shake -->
<section class="card" data-card>
<div class="top">
<label class="top__label" for="tags">Topics</label>
<p class="top__left"><span class="top__n"><span data-left>4</span></span> left</p>
</div>
<div class="field" data-field>
<ul class="tags" data-tags aria-label="Chosen topics"></ul>
<input id="tags" class="field__input" type="text" data-input autocomplete="off" autocapitalize="none" spellcheck="false" placeholder="Add a topic" aria-describedby="tags-hint">
</div>
<p class="hint" id="tags-hint"><span data-hint>Press Enter to add, Backspace to remove</span></p>
<div class="ideas" data-ideas role="group" aria-label="Suggestions">
<button type="button" data-idea>motion</button>
<button type="button" data-idea>typography</button>
<button type="button" data-idea>color</button>
<button type="button" data-idea>layout</button>
<button type="button" data-idea>accessibility</button>
</div>
</section>
<p class="sr" data-live aria-live="polite"></p>
<svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.2 19.2 11l-6.3 1.6-3.3 5.9Z"></path></svg>
</main>
<script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.min.js"></script>
<script src="script.js"></script>
</body>
</html>Change values, colours and text with the controls and watch the animation respond live. Or write in the code yourself. Then download the folder with your changes.
20 values to change
With the Animorio connector, Claude Code, ChatGPT, Cursor or VS Code take it from here, guide included, and fit it into your project. Paste this request:
Take “Tags input field” from Animorio and fit it into my siteThe box is a wrapping flex: inside are the pills and a real input, borderless, taking the room left. A click on an empty spot of the box puts the caret in the input.
Enter and comma call add: it strips spaces and commas, lowercases everything, rejects duplicates (the pill already there gives a nudge) and creates a list item with its cross. The pill is born at scale 0.6 and reaches 1 with elastic.out.
At every letter match compares the start of each suggestion with what is in the input: those that match take is-match, the others is-miss, the ones already used is-used.
On an empty field the first Backspace marks the last pill (is-armed) and the second removes it: so a tag is not deleted by mistake when holding the key. Any other key removes the mark.
Beyond MAX tags add creates nothing: the box shakes in four steps, the edge and the count turn red for 1.8 seconds and the help line says why.
| Name | File | Default | What it changes |
|---|---|---|---|
FIRST | script.js | design | The tag already there at the start (empty = none). |
MAX | script.js | 5 | How many tags at most. |
SPRING | script.js | 0.7 | How long the spring of the tag closing into a pill lasts, in seconds. |
ACCENT | script.js | #5b5bf0 | The colour of the tags. |
TYPE | script.js | 0.11 | By itself: the seconds between one letter and the next. |
PAUSE | script.js | 1.1 | By itself: the pause after each tag, in seconds. |
LOOP | script.js | true | Left alone, a pointer types, adds and removes. |
In the form to publish an article, upload a product, open a ticket or fill in a profile: wherever a few keywords chosen by the writer are needed, with some suggestions so duplicates are not invented.
The same field, as wide as the screen: the pills wrap and so do the suggestions. On a phone keyboard the comma also closes a tag.
No springs and no shake: the pills appear and go at once, the count changes without rolling and the limit is told only by colour and words.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 5.6 KB; the libraries: GSAP 28 KB.
Tested on 14 November 2026
Use it in your own projects and in your clients’ projects. Do not resell it or redistribute it as is. GSAP stays under its own Standard license. Full license.
Support Animorio
Animorio stays free thanks to the people who support it. If you like, buy us a coffee: it helps us make the next animations.
You asked for
We made it for you: it’s in the library, with the preview, the Playground and the code to copy.
An animation you can’t find, or a site to take apart in the journal: tell us which. We pick the next ones from here.
With your account’s email and password.
or with your email
You’re signed in as .
With your account, you can download the zip of every animation and every pack, for free.