
The elastic button
Buttons, Hover, Text
A restaurant’s «Book a table» button in the style of product interface pieces, on white: on click the black pill opens in place and inside there is the table seen from above. Adding guests, the chairs come to the table on a spring and the plates are laid, the number rolls, the time is picked from a segmented row; Reserve fills green and the pill closes back into «Table for 4 · 20:30» with a drawn check.
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>
<!--
"Book a table guests 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 Book a table button with the guests inside</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>
<!-- a black pill that opens in place: a table seen from above where the chairs come as you add guests,
the time as a row of segments, and Reserve; it closes back into the pill with the booking in it -->
<div class="booker" data-booker>
<div class="shell" data-shell>
<span class="shell__ink" data-ink aria-hidden="true"></span>
<span class="shell__edge" data-edge aria-hidden="true"></span>
<button class="face face--idle" type="button" data-open data-autoclic aria-expanded="false" aria-controls="panel">
<svg class="mini" data-mini viewBox="0 0 24 24" aria-hidden="true">
<circle cx="12" cy="12" r="4.6"></circle>
<path class="mini__chair" d="M10 3.6h4"></path>
<path class="mini__chair" d="M10 20.4h4"></path>
<path class="mini__chair" d="M3.6 10v4"></path>
<path class="mini__chair" d="M20.4 10v4"></path>
</svg>
<span class="face__label">Book a table</span>
</button>
<div class="panel" id="panel" data-panel aria-hidden="true">
<div class="row row--top" data-top>
<svg class="table" data-table viewBox="0 0 64 64" aria-hidden="true">
<g data-seats></g>
<circle class="table__top" cx="32" cy="32" r="14.5"></circle>
<circle class="table__shine" cx="32" cy="32" r="11.5"></circle>
<g data-plates></g>
</svg>
<div class="guests">
<p class="guests__label">Guests</p>
<div class="stepper">
<button class="step" type="button" data-minus aria-label="One guest fewer">
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M7 12h10"></path></svg>
</button>
<span class="count" aria-live="polite"><span class="count__roll" data-roll></span></span>
<button class="step" type="button" data-plus aria-label="One guest more">
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M7 12h10M12 7v10"></path></svg>
</button>
</div>
</div>
<button class="reserve" type="button" data-reserve aria-label="Reserve">
<span class="reserve__fill" data-reserve-fill aria-hidden="true"></span>
<svg viewBox="0 0 24 24" aria-hidden="true"><path class="reserve__arrow" d="M6 12h11.5M13 7.2l4.8 4.8-4.8 4.8"></path></svg>
</button>
</div>
<div class="times" role="radiogroup" aria-label="Time" data-times>
<span class="times__pill" data-indicator aria-hidden="true"></span>
</div>
<p class="foot" data-foot>Friday 31 October · Café Vireo</p>
</div>
<div class="face face--done" data-done aria-live="polite">
<svg class="tick" viewBox="0 0 24 24" aria-hidden="true"><path data-check d="m5.5 12.5 4.2 4.2 8.8-9.4"></path></svg>
<span data-booked>Table for 4</span>
</div>
</div>
<p class="note" data-note>Confirmation sent · <span>Café Vireo</span></p>
</div>
<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.
21 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 “Book a table guests button” from Animorio and fit it into my siteButton and capsule are the same element: a shell with hidden overflow whose width, height and corners GSAP takes from the pill’s size to the capsule’s, with back.out for the spring. Underneath there is a black layer that fades as it opens and a thin border that fades in: the black turns white without animating a background colour.
Six places around the top, each a group moved and turned towards the centre: inside there is the dashed outline and a group with the chair, which GSAP takes from y minus 5 and scale 0.6 to zero and one with back.out. The chairs are taken in a fixed order (two facing each other, then filling in), the plates are circles growing from their centre.
The number is a column of digits from 1 to 6 in a one-line window: to show n the column rises by n minus one lines with back.out, and meanwhile squashes slightly in height around the right digit, so you feel it roll.
The indicator is a white pill in absolute position with the x and width of the chosen time, read with offsetLeft and offsetWidth. A time can have a limit on guests: past it, it is struck through and the indicator moves to the first free time after it.
A single timeline: Reserve squashes and fills green from the centre, the arrow leaves, the content rises and fades, the shell becomes a pill as wide as «Table for 4 · 20:30», the check draws itself with strokeDashoffset and the pill sinks a pixel and rises again. A delayedCall brings back «Book a table»; the autopilot awaits the tweens as promises and stops at the first real touch.
| Name | File | Default | What it changes |
|---|---|---|---|
SPRING | script.js | 0.55 | How long the spring that opens and closes the pill lasts, in seconds. |
CHAIR_SPRING | script.js | 0.45 | How long the spring that brings a chair to the table lasts, in seconds. |
HOLD | script.js | 2.6 | How many seconds the booking stays before «Book a table» comes back. |
START_GUESTS | script.js | 2 | How many guests there are when it opens. |
MAX_GUESTS | script.js | 6 | The most guests, from 2 to 6. |
INK | script.js | #0a0a0a | The colour of the pill, the chairs and the Reserve button. |
WOOD | script.js | #e9e2d6 | The colour of the table top. |
CHECK_COLOR | script.js | #4ade80 | The colour of the check and of Reserve when it confirms. |
OPEN_WIDTH | script.js | 330 | How wide the open pill is, in pixels (it narrows if the window is narrower). |
For the «Book a table» button on the site of a restaurant, a bistro or a café, or in a booking app: whoever presses it picks how many people and what time without leaving the page, and the button itself remembers the booking.
The capsule takes at most the width of the box minus the margins and measures its own height; plus, minus and the times are at least 28 pixels tall and a tap does what a click does.
The pill neither stretches nor bounces: it becomes a capsule and a pill again at once, the chairs and plates fade in in place, the number changes without rolling, the indicator jumps into place, the check is already drawn and 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 8.4 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.