Skip to content
animorio
IT
All components

Giveaway entry button

Buttons, Hover, TransitionsGSAP, CSS onlyMediumCompressed weight: Demo 7.3 KBGSAP 28 KBFreeDownload the zip

The giveaway card of Kiln Roasters, a made-up coffee roaster: you can win a year of coffee, 2,481 people have entered and two days are left. On tap the elastic «Enter the giveaway» pill squashes and a ticket comes out of a slot under the figures in two pushes, like from a printer, with a toothed edge and a punched hole, its entry number #2482 rolling into place digit by digit; the entries go up by one, the pill becomes «You’re in» with a tick and below it «Share to get 2 more entries» arrives, which takes the ticket from 1 to 3 entries. On white, with a single tomato accent.

The code

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>
<!--
  "Giveaway entry 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>Giveaway entry button</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/wdth.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/jetbrains-mono@5.3.0/index.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <main class="stage">
    <!-- the giveaway card of Kiln Roasters, a made-up coffee roaster: what you can win, how many have entered and how
         long is left, and the elastic pill. On press the pill squashes, a ticket prints out of the slot with its
         entry number rolling into place, the entries go up by one and the pill becomes You're in -->
    <section class="card" data-card aria-label="Kiln Roasters giveaway">
      <span class="card__edge" aria-hidden="true"></span>

      <div class="prize">
        <span class="thumb" aria-hidden="true">
          <svg viewBox="0 0 40 40" data-thumb>
            <path class="bag" d="M12 9.5h16l1.6 4.2v18.6a2.2 2.2 0 0 1-2.2 2.2H12.6a2.2 2.2 0 0 1-2.2-2.2V13.7z"/>
            <path class="bag__fold" d="M10.4 13.7h19.2"/>
            <path class="bag__crimp" d="M13 11.4h14"/>
            <rect class="bag__label" x="14" y="18" width="12" height="9.5" rx="1.4"/>
            <path class="bean" d="M20 19.6c-1.9.6-2.6 3.4-1.2 5.3M20 19.6c1.9.6 2.6 3.4 1.2 5.3"/>
          </svg>
        </span>
        <div class="prize__txt">
          <p class="brand">Kiln Roasters · Giveaway</p>
          <h1 class="name">Win a year of coffee</h1>
          <p class="meta">One bag a week for twelve months</p>
        </div>
      </div>

      <div class="facts">
        <span class="fact"><span class="roll" data-count aria-hidden="true"></span><span class="fact__lab">entries</span></span>
        <span class="fact fact--end">Ends in <b>2d 14h</b></span>
      </div>

      <!-- the slot the ticket prints out of -->
      <div class="well" data-well aria-hidden="true">
        <span class="slot"></span>
        <div class="ticket" data-ticket>
          <span class="ticket__stub">
            <span class="hole"></span>
          </span>
          <span class="ticket__body">
            <span class="ticket__top">
              <span class="ticket__lab">Entry</span>
              <span class="ticket__num">#<span class="roll" data-num></span></span>
            </span>
            <span class="ticket__bottom">
              <span>Draw on Dec 15</span>
              <span class="ticket__entries"><span class="roll" data-mine></span> <span data-mine-lab>entry</span></span>
            </span>
          </span>
          <span class="ticket__shine" data-shine></span>
        </div>
      </div>

      <button class="pill" type="button" data-pill data-autoclic aria-label="Enter the giveaway">
        <span class="pill__bg" data-pill-bg aria-hidden="true"></span>
        <span class="pill__face" data-face="enter"><span class="pill__txt">Enter the giveaway</span></span>
        <span class="pill__face" data-face="in" aria-hidden="true">
          <svg class="tick" viewBox="0 0 16 16"><path d="M3.6 8.4 6.6 11.2 12.4 5" pathLength="1" data-tick/></svg>
          <span class="pill__txt">You’re in</span>
        </span>
      </button>

      <button class="share" type="button" data-share aria-hidden="true" tabindex="-1">
        <span class="share__face" data-sface="ask">
          <svg class="ico" viewBox="0 0 16 16"><path d="M8 2.2v7.6M5 5.1 8 2.2l3 2.9M3.4 8.6v3.6c0 .9.7 1.6 1.6 1.6h6c.9 0 1.6-.7 1.6-1.6V8.6"/></svg>
          <span>Share to get 2 more entries</span>
        </span>
        <span class="share__face" data-sface="done">
          <svg class="ico" viewBox="0 0 16 16"><path d="M3.6 8.4 6.6 11.2 12.4 5" pathLength="1" data-stick/></svg>
          <span>Link copied · 2 entries added</span>
        </span>
      </button>

      <p class="sr" aria-live="polite" data-live></p>
    </section>
  </main>

  <script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.min.js"></script>
  <script src="script.js"></script>
</body>
</html>

Playground

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.

35 values to change

Works with Claude, Claude Code, ChatGPT, Cursor, VS Code, Windsurf, Codex, Gemini CLI

Or ask your AI assistant for it

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 “Giveaway entry button” from Animorio and fit it into my site
Platform licenseFree on your sites and your clients’ sites. Want it inside a website builder, a template platform or a client dashboard? There’s a license for agencies and platforms.

What it does

On hover the pill’s label widens on the width axis and the ground swells with a bounce. On tap the pill squashes and springs back; under the entries box there is a dark slot, and the ticket comes out of it downwards, in two pushes with a short pause between them, while the card grows to make room. As it comes out, the entry number rolls from 0000 to 2482 one digit after another; then a light crosses the paper, the entries go up by one (only the last digit rolls) and the pill, now dark, says «You’re in» with a tick drawing itself. Below it «Share to get 2 more entries» appears: tapping it turns it into «Link copied · 2 entries added», the ticket sways hanging from the slot and its entries go up from 1 to 3. Tapping the pill again pulls the ticket back in and everything returns to the start. If nobody touches it, the demo does everything by itself and starts over.

How it works

The slot and the ticket

The ticket sits in a well with hidden overflow as tall as the slot, shifted up by 100% of its own height: GSAP stretches the well to the ticket’s height and meanwhile brings it down in four stretches (to halfway, a pause, a pixel too far, its place), so it comes out in pushes as from a printer.

The toothed edge

The bottom edge is a CSS mask: a transparent circle at the bottom, repeated every 0.62 em across, takes out a half circle at each step. The hole is a circle in the card’s colour with an inner shadow.

The rolling digits

Each digit is a window one line tall over a column from 0 to 9; to change the number each column is sent to its digit with yPercent, so in the entries count only the last one rolls, in the entry number all of them, one after another.

Values to change

NameFileDefaultWhat it changes
ENTRIESscript.js2481How many have entered before you.
PRINT_TIMEscript.js1.1Seconds the ticket takes to print out of the slot.
ROLL_TIMEscript.js0.7Seconds each digit takes to roll into place.
DIGIT_GAPscript.js0.08Seconds between one digit of the entry number and the next.
SQUASHscript.js0.9How flat the pill gets when pressed (1 = not at all).
SPRINGscript.js0.45How springy the pill is (lower = more bounce).
BONUSscript.js2The extra entries you get for sharing.
HOLDscript.js2.6Seconds the finished state stays before the demo starts over.
IDLEscript.js7Seconds after your last touch before the demo plays by itself again.

Try them in the Playground

When to use it

On the page of a prize contest, a social giveaway or a charity raffle: the ticket that comes out gives whoever enters proof they are in, and the share button arrives when interest is at its highest.

On phones

Everything is in em and the size depends on both the width and the height of the window, so the card fits the phone box whole even with the ticket out. The pill is as wide as the card, easy for a thumb; the share line is a real button, tall enough to tap.

With reduced motion

No springs, pushes or rolling: the ticket fades in already out, the numbers are right straight away and the faces of the pill and of the share line swap with a fade.

Pitfalls

  • The pill’s two faces are absolutely positioned, centred with inset 0 and flex: the longer «Enter the giveaway» in the flow would push the tick of «You’re in» off centre.
  • The well is stretched in measured pixels (the ticket’s offsetTop and offsetHeight), not percentages: GSAP does not read percentages back from CSS. On resize, if the ticket is out, it is measured again.
  • The tooth mask cuts the edge shadow too: the ticket’s border is an inner shadow, not a border, so it follows the teeth.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0, JetBrains Mono (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 7.3 KB; the libraries: GSAP 28 KB.

Testing

Tested on 1 December 2026

  • Desktop: Done
  • Phone: Done
  • Reduced motion: Done
  • Safari on iPhone: To do

License

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.

All components