
The star rating
Ratings, SVG, Hover
One button, one line: the white «Attach» pill with a paperclip drawn as a thin line; on tap the clip retracts along its own line, draws itself again in the accent colour astride the top edge, its long leg passing behind the pill, and the label becomes «Attached» with the file name in grey. On a second tap it comes off and turns back into an icon.
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>
<!--
"Attach button" 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 Attach button with the paperclip that clips onto the pill</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 button, one line: the paperclip draws itself and clips onto the top edge of the pill -->
<button class="attach" type="button" data-attach aria-pressed="false" aria-label="Attach">
<!-- the leg that goes behind the pill: drawn under it, so the edge hides it -->
<svg class="attach__clip attach__clip--back" viewBox="0 0 24 48" aria-hidden="true" data-clip>
<path class="attach__line" data-back d="M20 10V36a8 8 0 0 1-16 0V16"/>
</svg>
<span class="attach__body" data-body>
<span class="attach__slot" aria-hidden="true"></span>
<span class="attach__label" aria-hidden="true">
<span class="attach__word" data-word="on">Attach</span>
<span class="attach__word" data-word="off"><span data-done>Attached</span><span class="attach__file" data-file>report.pdf</span></span>
</span>
</span>
<!-- the part in front of the pill -->
<svg class="attach__clip attach__clip--front" viewBox="0 0 24 48" aria-hidden="true" data-clip>
<path class="attach__line" data-front d="M16 14V34a4 4 0 0 1-8 0V10a6 6 0 0 1 12 0"/>
</svg>
</button>
</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.
16 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 “Attach button” from Animorio and fit it into my siteThe clip is a single stroke split across two SVGs with the same size and position: the front part sits above the pill, the long leg below it. The pill’s white fill hides the leg under the edge: no masks, the stacking order is what closes the clip.
Both lines have a strokeDasharray equal to their length: to retract, the strokeDashoffset goes to the length, to redraw it comes back to zero, the front part first and then the leg. The move onto the edge happens while the line is not there, so it is never seen sliding.
The clip lands a pixel below its place and comes back up on an elastic spring; at the same moment the pill drops by 0.6 pixels and returns: it is the edge taking the clip.
The old word leaves before the new one arrives, which comes up from below with the wdth axis at 75 and lands at 100 with back.out: the two are never read together. The pill takes the width of the new word, measured in its final shape.
| Name | File | Default | What it changes |
|---|---|---|---|
ACCENT | script.js | #3657ff | The colour of the clip once attached. |
LABEL_ON | script.js | Attach | The word before. |
LABEL_OFF | script.js | Attached | The word after. |
FILE_NAME | script.js | report.pdf | The file name beside the word. |
TILT | script.js | -8 | How many degrees the clip leans on the edge. |
SPRING | script.js | 1 | How springy the press and the landing 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 each state stays when the button plays by itself. |
AUTO | script.js | true | The button plays the gesture by itself until someone touches it. |
For the button that attaches a file in an email, a chat or a form: the clip on the edge says by itself that the file is attached, and the name beside it says which.
On the phone the pill and the clip take their size from the screen (clamp on the shorter side); there is no hover, everything else is the same.
The clip and the words swap with a fade, with no springs or movement; the pill takes its new width at once.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 4.8 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.