Skip to content
animorio
IT
All components

Trade in button

Buttons, HoverGSAP, CSS onlyMediumCompressed weight: Demo 8.9 KBGSAP 28 KBFreeDownload the zip

A component in the premium style of Dribbble shots: the Trade in button of a phone shop, in brushed graphite on a warm dark page. At rest it shows the old phone's model and the most it is worth; pressed, it checks the phone (model, screen, battery) while a line of light scans its screen and the digits of the credit spin, then the digits stop one by one from the left on the value, the chip turns champagne and the phone lights up with a check.

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>
<!--
  "Trade in 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 Trade in button that values your old phone</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">
    <!-- the Trade in button of a phone shop, in brushed graphite on a warm dark page. On hover a stretched highlight
         follows the pointer across the brushed metal, the rim catches the light and the old phone in the well leans
         forward. Pressed, the button gives under the finger; then it checks the phone (model, screen, battery: the
         caption changes, a line of light scans the little phone) while the digits of the credit spin, and they stop
         one by one from the left on the value. The phone's screen lights up with a check, the chip turns champagne,
         a reflection crosses the metal and the caption says how much comes off the order. Then it goes back -->
    <div class="ti" data-wrap>
      <span class="ti__floor" data-floor aria-hidden="true"></span>
      <button class="ti__btn" type="button" data-btn aria-label="Trade in your Nova 12, up to $420 credit">
        <span class="ti__body" data-body>
          <span class="ti__metal" aria-hidden="true"></span>
          <span class="ti__spec" data-spec aria-hidden="true"></span>
          <span class="ti__scan" aria-hidden="true"><span class="ti__scan-band" data-band></span></span>
          <span class="ti__glint" aria-hidden="true"><span class="ti__glint-band" data-glint></span></span>
          <span class="ti__rim" aria-hidden="true"></span>
          <span class="ti__rim ti__rim--hot" data-rim aria-hidden="true"></span>
          <span class="ti__row">
            <span class="ti__well" data-well aria-hidden="true">
              <span class="ti__dev" data-dev>
                <svg viewBox="0 0 24 24">
                  <defs>
                    <clipPath id="ti-screen"><rect x="8.7" y="4.7" width="6.6" height="14" rx="1.1"/></clipPath>
                  </defs>
                  <rect class="ti__case" x="7" y="2.6" width="10" height="18.8" rx="2.5"/>
                  <rect class="ti__glass" x="8.7" y="4.7" width="6.6" height="14" rx="1.1"/>
                  <rect class="ti__lit" data-lit x="8.7" y="4.7" width="6.6" height="14" rx="1.1"/>
                  <path class="ti__speaker" d="M10.9 3.7h2.2"/>
                  <g clip-path="url(#ti-screen)">
                    <g data-scanline>
                      <rect class="ti__scanglow" x="8.2" y="-1.6" width="7.6" height="3.2"/>
                      <path class="ti__scanline" d="M8.4 0h7.2"/>
                    </g>
                  </g>
                  <path class="ti__check" data-check pathLength="1" d="M9.9 11.9l1.5 1.5 2.7-3"/>
                </svg>
              </span>
            </span>
            <span class="ti__text" aria-hidden="true">
              <span class="ti__stack">
                <span class="ti__label" data-label>Trade in</span>
                <span class="ti__label" data-label>Estimating</span>
                <span class="ti__label" data-label>Credit applied</span>
              </span>
              <span class="ti__stack ti__stack--cap">
                <span class="ti__cap" data-cap>Nova 12 · 128 GB</span>
                <span class="ti__cap" data-cap>Checking model</span>
                <span class="ti__cap" data-cap>$340 off your order</span>
              </span>
            </span>
            <span class="ti__chip" aria-hidden="true">
              <span class="ti__chip-fill" data-fill></span>
              <span class="ti__face" data-face>Up to $420</span>
              <span class="ti__face ti__odo" data-face><span class="ti__cur">$</span><span class="ti__cols" data-cols></span></span>
            </span>
          </span>
        </span>
      </button>
    </div>
    <p class="sr" aria-live="polite" data-live></p>
  </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.

26 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 “Trade in 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 a near black page, warmed in the middle by a honey light and covered by a fine grain, there is a 60 pixel tall pill button in brushed graphite: the thin lines of the metal run sideways, the one pixel rim catches light on top and a warm thread underneath, and under the button a golden light rests on the floor. On the left, in a round well cut into the metal, there is the drawing of an old phone; in the middle ‘Trade in’ and under it, small, the model ‘Nova 12 · 128 GB’; on the right a chip says ‘Up to $420’. When the pointer passes, a tall narrow highlight, like the one on real brushed metal, follows it, the rim lights up just above and below it and the phone leans forward on a spring. Pressed, the metal gives under the finger and comes back with a bounce; the word turns into ‘Estimating’ and below it go ‘Checking model’, ‘Checking screen’, ‘Checking battery’, while a line of light runs up and down the phone's screen, a soft champagne band sweeps back and forth over the metal and in the chip the digits of the credit spin fast and a little blurred. Then the digits stop one at a time from the left, each passing its mark by a hair and settling: $340. The chip fills with champagne on a bounce, the phone's screen lights up with a check that draws itself, a reflection crosses the metal, the rim flashes once and the words say ‘Credit applied’ and ‘$340 off your order’. Two seconds later it goes back. On its own it loops until someone touches it.

How it works

Brushed metal without images

The graphite is a vertical gradient with a stretched SVG feTurbulence noise on top (baseFrequency 0.003 across and 0.95 down), which becomes thin horizontal lines, blended in soft-light. The highlight on brushed metal runs across the lines: that is why the pointer's light is an ellipse 70 pixels tall and 34 wide, in screen.

The one pixel rim

The rim is an element with 1 px of padding and the content-box mask in exclude: only the ring is left, with a light gradient on top and a warm one underneath. A second identical ring has two radial spots at the pointer's x and lights up on hover, while working and with a flash at the end.

The rolling digits

Each digit is a column 1.2 em tall holding a strip of forty digits; the position is a decimal number and the strip moves by that position modulo 10 times 1.2 em. While working a GSAP ticker moves them at different speeds; to stop them the next position with the right digit, plus one turn, is worked out and reached with a back.out, from left to right.

One cell for two faces

The chip holds ‘Up to $420’ and the digits in the same grid cell, so it takes the width of the wider one and nothing shifts when they swap. The same goes for the three words and the three small lines.

The direction

The job is a GSAP timeline: the checks swap at equal steps inside DURATION, then the digits stop and the last one calls the success. The success is another timeline with the chip, the check drawn with stroke-dashoffset, the reflection and the rim's flash; a delayedCall takes everything back to rest.

Values to change

NameFileDefaultWhat it changes
DEVICEscript.js'Nova 12 · 128 GB'The old phone, under the word at rest.
UP_TOscript.js420The most the shop pays: the chip at rest.
CREDITscript.js340The credit the phone is worth, where the digits stop.
CHECKSscript.js'model,screen,battery'What it checks while it works, one after the other.
DURATIONscript.js2.6Seconds of checking before the digits start to stop.
SPINscript.js16How fast the digits spin, in digits per second.
SPRINGscript.js1How springy the press and the settle are: 0.4 calm, 2 very bouncy.
HOLDscript.js2.2Seconds it stays on Credit applied before going back.
AUTOscript.jstrueGoes round by itself until someone touches it.

Try them in the Playground

When to use it

On the product page of a phone, laptop or watch in an online shop, next to the price: the button to trade in the old device and see right away how much is saved. It also fits the cart or checkout of an electronics shop.

On phones

On the phone the button is at most 88% of the screen wide and stays 60 pixels tall; there is no hover, so the highlight lights up under the finger at the touch, and the rest, digits and check included, is the same.

With reduced motion

Nothing moves: the phone does not lean, the line of light and the band are not there, the digits do not spin but fade in already on the value, the words swap in place and the chip, the screen and the check fade in.

Pitfalls

  • GSAP cannot animate a colour written as var(--…): the digits' colour is given as a real value and removed at the end with clearProps.
  • The line changing check and the final swap touch the same words: the check's timeline is stopped before the success, otherwise with reduced motion the old words come back over the new ones.
  • Without a fixed line height on the strip the digits sit a few tenths of an em below the dollar: each digit has a height and line height of 1.2 em.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 2 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