
The elastic button
Buttons, Hover, Text
The country select dropdown of a made-up shop’s shipping address form, clean and premium on white: on click the field itself becomes the list and grows downward with staggered options; inside there is a small search, and as you type the options that do not match close on a spring while the matching letters light up. A pill follows the active option with the mouse and the arrow keys, choosing folds the list back into the field, the new country rises in place of the old one and the phone code below rolls digit by digit.
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>
<!--
"Country select dropdown" 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>The country select dropdown with the search that closes the options</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 Country select of a made-up shop's shipping address form: the field opens into its own list, a small search
inside closes the countries that do not match on a spring, a pill follows the active one, and the phone code
below rolls to the chosen country -->
<form class="wrap" data-wrap autocomplete="off" onsubmit="return false">
<p class="head"><span class="head__brand">Ivelle</span><span class="head__sep" aria-hidden="true"></span><span class="head__title">Shipping address</span></p>
<div class="slot">
<div class="box" data-box>
<button class="field" type="button" data-field role="combobox" aria-haspopup="listbox" aria-expanded="false"
aria-controls="country-list" aria-labelledby="country-label country-value">
<span class="field__label" id="country-label">Country</span>
<span class="field__val" id="country-value" data-val></span>
<svg class="field__chev" data-chev viewBox="0 0 24 24" aria-hidden="true"><path d="M7 10l5 5 5-5"></path></svg>
</button>
<div class="body" data-body hidden>
<span class="body__rule" data-rule aria-hidden="true"></span>
<label class="search" data-search>
<svg class="search__ic" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="6.2"></circle><path d="M15.6 15.6 19.6 19.6"></path></svg>
<input class="search__in" data-input type="text" role="combobox" aria-autocomplete="list" aria-expanded="true"
aria-controls="country-list" aria-label="Search countries" placeholder="Search countries" spellcheck="false">
<button class="search__clear" type="button" data-clear aria-label="Clear the search" tabindex="-1">
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M8 8l8 8M16 8l-8 8"></path></svg>
</button>
</label>
<div class="list" data-scroll>
<ul class="list__ul" id="country-list" role="listbox" aria-label="Countries" data-list>
<li class="hl" data-hl aria-hidden="true"></li>
</ul>
<p class="empty" data-empty aria-hidden="true">No country matches</p>
</div>
</div>
</div>
</div>
<div class="phone">
<span class="phone__label" id="phone-label">Phone</span>
<span class="phone__row">
<span class="dial" data-dial aria-hidden="true"></span>
<span class="phone__rule" aria-hidden="true"></span>
<input class="phone__in" type="tel" inputmode="tel" aria-labelledby="phone-label" data-dialsr placeholder="Mobile number">
</span>
</div>
<div class="key" data-key aria-hidden="true">
<svg class="key__arrow" data-keyarrow viewBox="0 0 24 24"><path d="M12 6v12M7 13l5 5 5-5"></path></svg>
<span class="key__word" data-keyword>Enter</span>
</div>
<p class="sr" data-live aria-live="polite"></p>
</form>
<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.
22 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 “Country select dropdown” from Animorio and fit it into my siteThe field and the list live in the same absolutely positioned box inside a slot as tall as the field: on opening the list part shows, the full height is measured and GSAP takes the height from the field’s to the full one with back.out, then frees it. So the field’s border becomes the list’s border and the box passes over the phone field.
Each option is an li with overflow hidden: the ones that do not match lose their content first (fade and scale 0.94) and then their height down to zero, and finally get the hidden attribute; the ones that come back grow to one row with back.out. The name is rewritten with a mark around the matching letters.
One absolute element inside the list goes to the active option’s offsetTop on a spring; while options close, the filter timeline places it on every frame, so it never sits on an empty row. The list scrolls through its scrollTop to keep the option in view.
The field is a button with role combobox and aria-expanded; the search is a combobox input that points to the listbox and announces the active option with aria-activedescendant. Arrows, Home, End, Page Up and Down, Enter to choose, Esc to clear the search and then close; an aria-live region says how many countries are left and the new phone code.
The old value leaves upward and the new one enters from below in a 22 pixel window with back.out, which lands it a pixel too far and brings it back; the phone code is split into digits that rise staggered, while its width goes to the measured width of the new text.
| Name | File | Default | What it changes |
|---|---|---|---|
START | script.js | GB | The code of the country chosen at the start. |
ACCENT | script.js | #3f4fe8 | The colour of the matching letters, the check and the focus border. |
ROWS | script.js | 4.5 | How many options show in the open list before it scrolls. |
OPEN_TIME | script.js | 0.55 | How many seconds the spring that opens the list from the field lasts. |
PILL_SPRING | script.js | 1.5 | How much the pill following the active option bounces. |
STAGGER | script.js | 0.028 | The stagger between one option and the next as the list opens. |
TYPE_PAUSE | script.js | 0.38 | The seconds between the letters typed by the drawn pointer. |
In an online shop’s checkout, in a shipping or billing address form, in an app’s sign up or a user profile: wherever a country is picked from a long list and the phone code has to follow it.
The form narrows to the screen width, fields and rows are sized on the height too and the open list stays inside the room kept under the field; a finger opens, scrolls the list and chooses like the mouse, and the pill goes to the tapped option.
No springs or movement: the list fades in and out, filtered options disappear at once, the pill jumps to the active option and the new value and phone code fade in; the drawn pointer is not shown.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 9.7 KB; the libraries: GSAP 28 KB.
Tested on 13 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.