
The elastic button
Buttons, Hover, Text
The Trick or treat button of a Halloween party, on black, in a minimal style: a single idea, a carved slit. Hovering it, a thin cut shaped like a pumpkin’s eye opens inside the pill and an orange candlelight flickers through it, warming the edge. On click the pill squashes and springs back, the light flares, the label turns into Treat and a wrapped sweet, drawn in two lines, jumps out of the slit and lands on the button’s edge.
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>
<!--
"Trick or treat 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 Trick or treat button with candlelight in the slit</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 idea: a carved slit. On hover a thin pumpkin-eye slit opens in the pill and candlelight flickers
through it; on click the light flares, the label turns to Treat and a wrapped sweet jumps out and lands -->
<section class="door" data-door aria-label="Trick or treat at Hollow Lane">
<p class="door__head"><span class="door__name">Hollow Lane</span><span class="door__date">Oct 31 · from 7 pm</span></p>
<div class="door__wrap" data-wrap>
<span class="glow" data-glow aria-hidden="true"></span>
<button class="btn" type="button" data-btn aria-pressed="false">
<span class="btn__fill" aria-hidden="true"><span class="btn__warm" data-warm></span></span>
<span class="btn__row">
<span class="slit" data-slit aria-hidden="true">
<svg viewBox="0 0 28 18">
<defs>
<clipPath id="occhio"><path d="M4.2 15.4C2.6 13.2 4.4 10.6 8.4 9.2L25.6 2.4C23.4 9.6 17 14.8 4.2 15.4Z"></path></clipPath>
<radialGradient id="fiamma" cx="40%" cy="70%" r="75%">
<stop offset="0" stop-color="#fff1c9"></stop>
<stop offset="0.35" stop-color="#ffb24a"></stop>
<stop offset="0.8" stop-color="#ff7a1a"></stop>
<stop offset="1" stop-color="#8a2e00"></stop>
</radialGradient>
</defs>
<g clip-path="url(#occhio)">
<rect class="slit__dark" x="0" y="0" width="28" height="18"></rect>
<g data-lid><rect class="slit__light" data-light x="0" y="0" width="28" height="18" fill="url(#fiamma)"></rect></g>
</g>
<path class="slit__edge" data-edge d="M4.2 15.4C2.6 13.2 4.4 10.6 8.4 9.2L25.6 2.4C23.4 9.6 17 14.8 4.2 15.4Z"></path>
</svg>
</span>
<span class="btn__labels">
<span class="btn__label" data-label="trick">Trick or treat</span>
<span class="btn__label btn__label--treat" data-label="treat">Treat</span>
</span>
</span>
</button>
<svg class="sweet" data-sweet viewBox="0 0 44 22" aria-hidden="true">
<g data-sweet-body>
<path class="sweet__twist" d="M9 11 2.5 5.2 3.6 11 2.5 16.8Z"></path>
<path class="sweet__twist" d="M35 11 41.5 5.2 40.4 11 41.5 16.8Z"></path>
<rect class="sweet__wrap" x="9" y="4.5" width="26" height="13" rx="6.5"></rect>
<path class="sweet__stripe" d="M17 4.9 13.6 17.1M24 4.6 20.6 17.4M31 4.9 27.6 17.1"></path>
<path class="sweet__shine" d="M13 7.6h6"></path>
</g>
</svg>
<span class="sweet__shadow" data-shadow aria-hidden="true"></span>
</div>
<p class="door__hint"><span data-hint="a">Knock, if you dare</span><span data-hint="b">One sweet per visitor</span></p>
</section>
<svg class="ptr" data-ptr viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.2v15.6l4.3-4.1 2.8 6.3 2.6-1.1-2.8-6.2h5.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.
20 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 “Trick or treat button” from Animorio and fit it into my siteThe pumpkin eye is a path in a clipPath: inside sits the dark and over the dark a rectangle with a radial candle gradient, paler at the bottom. Opening the slit means scaling it in height from a tenth to one, from the bottom, with back.out.
A level from zero to one that the states aim at (closed, open, rewarded), multiplied by how open the slit is and by a flicker made of three out-of-phase sines. The same number drives the light in the slit, the glow inside the pill, the edge and the halo outside.
The level rises to 1.6 in seven hundredths and comes back to one in nearly a second: the candle flares and settles. Meanwhile the pill squashes for nine hundredths and springs back with elastic.out.
The sweet starts small in the middle of the slit and goes to the button’s top edge on an arc worked out by hand: x linear, y with a sine as high as SALTO, the spin unwinding to zero. On landing it squashes from below and rocks once.
Trick or treat and Treat sit in the same grid cell: the first leaves upwards with a blur, the second comes in from below a moment later. So the button keeps its width and the two words are never read together.
| Name | File | Default | What it changes |
|---|---|---|---|
ETICHETTA | script.js | "Trick or treat" | The button’s label. |
PREMIO | script.js | "Treat" | The label after the click. |
SFARFALLIO | script.js | 0.35 | How much the candlelight flickers in the slit. |
APERTURA | script.js | 0.55 | How long the slit takes to open, in seconds. |
SALTO | script.js | 64 | How high the sweet jumps, in pixels. |
VAMPA | script.js | 1.6 | How bright the light flares on click before settling. |
In a Halloween party invitation, on a sweet shop’s page at the end of October, on a seasonal offer button, on a site that dresses up for the night for a week.
The same pill, shorter if the screen is short. Without a mouse the first tap opens the slit and presses at once: the light comes on and the sweet jumps straight away.
The slit opens without a spring, the light neither flickers nor flares, the labels swap with a fade and the sweet appears already resting on the edge, without a jump. The drawn pointer does not run.
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 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.