
The elastic button
Buttons, Hover, Text
One sign does everything: on white there is only a lens; on tap a thin line stretches out on both sides and becomes the field, the lens slides to the end and there its handle runs through it, the ring winds itself closed and a second stroke draws across: it has become the cross that clears the field. The search types itself, three results rise below in thin staggered rows, and the cross folds everything back into the lens.
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>
<!--
"Search field with lens" 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 search field with the lens that turns into the cross</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" data-stage>
<!-- one sign: the lens stretches into a field, and its handle and its ring become the cross that clears it -->
<div class="find" data-find>
<div class="find__field" data-field>
<span class="find__line" data-line aria-hidden="true"></span>
<label class="find__box" data-box>
<span class="visually-hidden">Search the shop</span>
<input class="find__input" data-input type="search" autocomplete="off" spellcheck="false" placeholder="Search" tabindex="-1" aria-controls="find-list">
</label>
<button class="find__sign" data-sign type="button" aria-label="Search" aria-expanded="false">
<span class="find__sign-in" data-sign-in>
<svg viewBox="0 0 24 24" aria-hidden="true">
<circle class="find__ring" data-ring cx="10.5" cy="10.5" r="5.6"/>
<line class="find__stroke" data-handle x1="14.6" y1="14.6" x2="19" y2="19"/>
<line class="find__stroke" data-cross x1="18" y1="6" x2="6" y2="18"/>
</svg>
</span>
</button>
</div>
<ul class="find__list" id="find-list" data-list role="listbox" aria-label="Results"></ul>
</div>
</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.
39 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 “Search field with lens” from Animorio and fit it into my siteOpen or closed is a number from 0 to 1: place() uses it for the scale of the line, which stretches from the middle, and for the travel of the lens, which starts in the middle and ends at the far right. The same number recomputes everything on resize, even halfway through opening.
The sign is an SVG of three strokes: the ring, the handle and the cross’s second stroke. The handle stretches its ends to the two corners, the ring winds closed with strokeDashoffset while shrinking to the centre, the second stroke draws, and the group turns 90 degrees with back.out: that is the settle. On the way back the same in reverse, with the second stroke leaving from the far end.
search() keeps the products containing every word typed, SHOWN at most; lit() wraps the letters found in a b. If the list does not change only the lit letters update, without restarting the rows; if it does, the old ones leave and the new ones rise staggered, with the thin rule and the price a moment later.
The field’s own caret is transparent and a blue line takes its place: a hidden span in the same font measures the text typed and the line slides behind it, so it shows even while the search types itself.
| Name | File | Default | What it changes |
|---|---|---|---|
ACCENT | script.js | #2f5bff | The colour of the caret and of the letters found. |
QUERY | script.js | linen shirt | What the search types by itself. |
PLACEHOLDER | script.js | Search | The word in the empty field. |
SHOWN | script.js | 3 | How many results at most. |
SPRING | script.js | 1 | How springy the sign and the rows are: 0.4 calm, 2 very bouncy. |
SPEED | script.js | 1 | The speed of everything: 2 twice as fast, 0.5 half. |
HOLD | script.js | 2.4 | How many seconds the results stay when the search plays by itself. |
AUTO | script.js | true | The search plays the gesture by itself until someone touches it. |
For the search of an online shop, a blog or an app that should stay folded into an icon until it is needed: the same icon is also the button that clears and closes it, with no second sign to look for.
On the phone the field takes the full width minus the margins and the text sizes follow the shorter side; there is no hover, everything else is the same.
The line, the lens, the cross and the rows appear and disappear with a fade, with no springs or movement.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 6.1 KB; the libraries: GSAP 28 KB.
Tested on 30 October 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.