Skip to content
animorio
IT
All components

Tip selector

Pickers, Hover, PhysicsGSAP, CSS onlyMediumCompressed weight: Demo 9.4 KBGSAP 28 KBFreeDownload the zip

The tip at the end of a delivery order, on black: four pills, 10, 15, 20% and Custom, with a light indicator that slides from one to the next on a spring and stretches towards where it runs. Tip and total roll digit by digit, the thank-you line changes words and tone with the percentage, from a quiet grey to a warm orange; Custom widens, becomes a field with a caret and a numeric keypad rises from the bottom of the card.

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>
<!--
  "Tip selector" 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 tip selector with the pills and the keypad that rises</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>
    <!-- the tip at the end of a delivery order: four pills with a light indicator that slides on a spring,
         tip and total that roll digit by digit, a thank-you line that changes tone, and Custom that opens a field
         inside its pill while a numeric keypad rises from the bottom of the card -->
    <div class="scale" data-frame>
      <section class="card" data-card aria-label="Tip your courier">
        <span class="card__light" aria-hidden="true"></span>

        <header class="head">
          <span class="avatar" aria-hidden="true"><span class="avatar__in">IM</span></span>
          <div class="head__text">
            <p class="head__title">Tip Ines</p>
            <p class="head__meta">Delivered 12:48 · Kumo Noodle Bar</p>
          </div>
          <span class="head__order" data-order>$28.40</span>
        </header>

        <div class="seg" data-seg role="radiogroup" aria-label="Tip amount">
          <span class="seg__ind" data-ind aria-hidden="true"></span>
          <button class="pill" type="button" role="radio" aria-checked="false" data-pct="10">
            <span class="pill__face"><span class="pill__main">10%</span><span class="pill__sub" data-sub></span></span>
          </button>
          <button class="pill" type="button" role="radio" aria-checked="false" data-pct="15">
            <span class="pill__face"><span class="pill__main">15%</span><span class="pill__sub" data-sub></span></span>
          </button>
          <button class="pill" type="button" role="radio" aria-checked="false" data-pct="20">
            <span class="pill__face"><span class="pill__main">20%</span><span class="pill__sub" data-sub></span></span>
          </button>
          <button class="pill pill--custom" type="button" role="radio" aria-checked="false" aria-expanded="false" data-custom>
            <span class="pill__face pill__face--rest" data-rest><span class="pill__main">Custom</span><span class="pill__sub">Any amount</span></span>
            <span class="pill__face pill__face--field" data-fieldface aria-hidden="true">
              <span class="pill__main pill__main--field"><span class="roll" data-cval></span><span class="caret" data-caret></span></span>
              <span class="pill__sub">Custom</span>
            </span>
          </button>
        </div>

        <div class="rows">
          <div class="row">
            <span class="row__label">Tip</span>
            <span class="row__value roll" data-tip aria-live="polite"></span>
          </div>
          <div class="row row--total">
            <span class="row__label">Total</span>
            <span class="total roll" data-total></span>
          </div>
        </div>

        <p class="thanks" data-thanks aria-live="polite"></p>

        <div class="pad" data-pad>
          <div class="pad__in" data-padin>
            <button class="key" type="button" data-k="1">1</button>
            <button class="key" type="button" data-k="2">2</button>
            <button class="key" type="button" data-k="3">3</button>
            <button class="key" type="button" data-k="4">4</button>
            <button class="key" type="button" data-k="5">5</button>
            <button class="key" type="button" data-k="6">6</button>
            <button class="key" type="button" data-k="7">7</button>
            <button class="key" type="button" data-k="8">8</button>
            <button class="key" type="button" data-k="9">9</button>
            <button class="key key--back" type="button" data-k="back" aria-label="Delete">
              <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M9 6h10.5a1.5 1.5 0 0 1 1.5 1.5v9a1.5 1.5 0 0 1-1.5 1.5H9l-5.5-6Z"></path><path d="M12.5 9.6l4.8 4.8M17.3 9.6l-4.8 4.8"></path></svg>
            </button>
            <button class="key" type="button" data-k="0">0</button>
            <button class="key key--done" type="button" data-k="done" aria-label="Done">
              <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 12.4l4 4L18.2 8"></path></svg>
            </button>
          </div>
        </div>
      </section>
    </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>

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.

40 values to change

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 “Tip selector” 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 black, the dark end-of-order card: Ines’s avatar, Tip Ines, delivered at 12:48 from Kumo Noodle Bar, and the 28.40 dollar order in a small pill. Below, a groove with four pills: 10%, 15% and 20% with the amount underneath, and Custom with Any amount. A light indicator, with a thread of light on its top edge, sits behind the choice: tap another pill and it runs there on a spring, stretches towards where it goes, squashes a little and settles one pixel too far. Tip and total roll digit by digit, up when they grow and down when they shrink. The thank-you line changes its words, one at a time with a blur, and its tone: grey and thin at 10%, white at 15%, orange, bolder and wider at 20% and above; the light on the card’s edge warms up too. Custom widens and becomes a field with the amount and an orange caret, and the numeric keypad rises from the bottom of the card, row after row: you type as at a till (4, 5, 0 makes 4.50 dollars), the arrow deletes, the orange check closes.

How it works

The indicator on a spring

The indicator’s position and width chase those of the chosen pill with a damped spring (STIFFNESS and DAMPING), integrated in four steps per frame on GSAP’s ticker. The target is measured again every frame, so the indicator follows the Custom pill while it widens.

The stretch

Speed stretches the indicator on the side it runs towards (STRETCH) and squashes it a few hundredths in height: when it stops it is as wide as the pill again.

Rolling digits

Every character sits in a window one line high: when it changes, the old one leaves and the new one comes in with back.out, up or down depending on the number, the digits on the right a moment before those on the left.

The tone of the thanks

The real percentage gives a sentence and a tone: colour, weight and the wdth axis of the variable font animate as CSS variables, the words leave and come back blurred one at a time and the light on the card’s edge grows stronger.

Custom and the keypad

Custom takes more room with an animated flex-grow and its two faces swap; the keypad is a box zero high that opens to its measured height while the keys rise row by row. The amount is typed as at a till, in cents, up to 99.99.

Values to change

NameFileDefaultWhat it changes
SUBTOTALscript.js28.40The order before the tip, in dollars.
CHOICESscript.js10,15,20The three percentages of the pills.
STARTscript.js15The pill chosen at the start.
NAMEscript.jsInesThe name of the courier to thank.
STIFFNESSscript.js520How stiff the indicator’s spring is.
DAMPINGscript.js33How much the spring brakes: lower, it wobbles more.
STRETCHscript.js0.035How much the indicator stretches while it runs.
CUSTOM_GROWscript.js1.7How much the open Custom pill widens.
ACCENTscript.js#ff9b55The warm colour of generous tips, the check key and the caret.

Try them in the Playground

When to use it

At the end of an order in a delivery app, at the till of a café or a restaurant, in the payment of a taxi or a home service: anywhere a tip is left among three handy choices and a free amount.

On phones

The card takes the screen width minus the margins, pills and keys get shorter with the window’s height and the open keypad stays inside the box. A tap does everything a click does.

With reduced motion

Nothing moves: the indicator jumps straight onto the chosen pill, the digits change in place, the sentence and the keypad fade in and the caret stays still. The autopilot does not start.

Pitfalls

  • With tabular figures Mona Sans uses the slashed zero: the numbers stay proportional and every window of the roll takes the width of the wider character between the old and the new one until the change is over.
  • While Custom widens the other pills shrink: a target measured only once left the indicator crooked, so the spring reads the pill again every frame while flex-grow animates.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 11 November 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