
The elastic button
Buttons, Hover, Text
Picking a coach on a train ticket: six coaches in a row, A to F, each with its windows and a small bar saying how full it is. Pick one and the train slides along the rails and stops with a slight bounce bringing it to the middle; at the top the free seats count to the new number and below it rolls what the coach is for: quiet, bistro, bikes, families. The button picks it and confirms with a tick.
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>
<!--
"Train coach picker" 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>Train coach picker</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">
<!-- picking a coach on a train ticket: the coaches stand in a row with how full they are, the train slides
to bring the chosen one to the middle, and below it its free seats roll in with what the coach is for -->
<section class="tc" data-tc aria-labelledby="tc-title">
<header class="tc__head">
<span class="tc__name"><b id="tc-title">Choose your coach</b><span>IC 512 to Lyon, leaves 14:07</span></span>
<span class="tc__free" aria-live="polite"><b><span data-outfree>23</span></b><span class="tc__freeword"><span data-freeword>seats free</span></span></span>
</header>
<div class="tc__rail" data-rail>
<div class="tc__train" data-train role="group" aria-label="Coaches">
<span class="tc__nose" aria-hidden="true"></span>
<button class="tc__coach" type="button" data-coach data-letter="A" data-kind="First class" data-note="Wide seats, power at every seat" data-free="12" data-seats="48" aria-pressed="false" aria-label="Coach A, First class, 12 seats free"><b>A</b><span class="tc__win" aria-hidden="true"><i></i><i></i><i></i></span><span class="tc__load" aria-hidden="true"><i style="width:75%"></i></span></button>
<button class="tc__coach" type="button" data-coach data-letter="B" data-kind="Standard" data-note="Nearly full, tables for four" data-free="4" data-seats="64" aria-pressed="false" aria-label="Coach B, Standard, 4 seats free"><b>B</b><span class="tc__win" aria-hidden="true"><i></i><i></i><i></i></span><span class="tc__load" aria-hidden="true"><i style="width:94%"></i></span></button>
<button class="tc__coach" type="button" data-coach data-letter="C" data-kind="Quiet zone" data-note="No calls, phones on silent" data-free="23" data-seats="64" aria-pressed="true" aria-label="Coach C, Quiet zone, 23 seats free"><b>C</b><span class="tc__win" aria-hidden="true"><i></i><i></i><i></i></span><span class="tc__load" aria-hidden="true"><i style="width:64%"></i></span></button>
<button class="tc__coach" type="button" data-coach data-letter="D" data-kind="Bistro" data-note="Coffee and sandwiches, no seats" data-free="0" data-seats="0" aria-pressed="false" aria-label="Coach D, Bistro, no seats"><b>D</b><span class="tc__win" aria-hidden="true"><i></i><i></i><i></i></span><span class="tc__load" aria-hidden="true"><i style="width:100%"></i></span></button>
<button class="tc__coach" type="button" data-coach data-letter="E" data-kind="Bikes" data-note="Six bike hooks, fold-down seats" data-free="31" data-seats="56" aria-pressed="false" aria-label="Coach E, Bikes, 31 seats free"><b>E</b><span class="tc__win" aria-hidden="true"><i></i><i></i><i></i></span><span class="tc__load" aria-hidden="true"><i style="width:45%"></i></span></button>
<button class="tc__coach" type="button" data-coach data-letter="F" data-kind="Family" data-note="Play corner, space for prams" data-free="40" data-seats="64" aria-pressed="false" aria-label="Coach F, Family, 40 seats free"><b>F</b><span class="tc__win" aria-hidden="true"><i></i><i></i><i></i></span><span class="tc__load" aria-hidden="true"><i style="width:38%"></i></span></button>
</div>
<span class="tc__track" aria-hidden="true"></span>
</div>
<div class="tc__info">
<button class="tc__step" type="button" data-prev aria-label="Previous coach"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M9.500 3.500 5 8l4.500 4.500"></path></svg></button>
<span class="tc__what"><b class="tc__roll"><span data-outkind>Quiet zone</span></b><span class="tc__roll tc__roll--sub"><span data-outnote>No calls, phones on silent</span></span></span>
<button class="tc__step" type="button" data-next aria-label="Next coach"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M6.500 3.500 11 8l-4.500 4.500"></path></svg></button>
</div>
<button class="tc__go" type="button" data-go><svg viewBox="0 0 16 16" aria-hidden="true"><path pathLength="1" d="m3.500 8.300 3 3 6-6.600"></path></svg><span class="tc__gotext"><span data-golabel>Pick coach C</span></span></button>
</section>
<svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.200 19.200 11l-6.300 1.600-3.300 5.900Z"></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.
26 values to change
Works with Claude, Claude Code, ChatGPT, Cursor, VS Code, Windsurf, Codex, Gemini CLI
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 “Train coach picker” from Animorio and fit it into my siteThe coaches are buttons in a row wider than the card. The shift is half the rail’s width minus the centre of the chosen coach: GSAP takes the row’s x there on a spring, and a mask fades both edges.
Two numbers: the coach looked at and the one picked. From there the lit edge, the arrows off at both ends, the button’s label and the button disabled when the coach has no seats.
Each coach carries its data in attributes. The number of free seats is an object taken to the new value in COUNT seconds and written rounded, while the words roll in the train’s direction.
| Name | File | Default | What it changes |
|---|---|---|---|
ACCENT | script.js | #ff6a3d | The colour of the chosen coach and of the button. |
START | script.js | C | The coach chosen on opening, from A to F. |
GLIDE | script.js | 1 | How long the train takes to slide to the chosen coach. |
On the site of a railway company or a travel agency, at the booking step where you choose where to sit; and on event and hotel sites selling the train together with the ticket or the room. With other boxes it works for a ferry’s decks or a stadium’s sectors.
The same card, as wide as the screen minus the margins: three whole coaches show with the two at the sides fading, the arrows are 34 pixels wide and the train recentres by itself on resize. The card is about 285 pixels tall and fits the phone box.
The train does not slide: the chosen coach is in the middle at once, the free seats change without counting and the labels without rolling. The demo’s pointer does not start.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 6.2 KB; the libraries: GSAP 28 KB.
Tested on 25 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.
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.