Skip to content
animorio
IT
Back to the library

Crypto swap card

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

The swap card of a crypto app: what you pay, what you receive, the rate and the Swap button. Type an amount and the other counts to its value. The disc in the middle turns and the two tokens trade places on arcs while the amounts cross and the rate rolls over. Swap lets a light run through it, becomes “Swapped” with a tick and the balances count to their new values.

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>
<!--
  "Crypto swap card" 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>Crypto swap card</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 swap card of a crypto app: type an amount and the other side counts to its value, the round
         button turns and the two tokens trade places on arcs, the rate rolls over, Swap confirms -->
    <section class="sw" data-sw aria-label="Swap tokens">
      <header class="sw__head">
        <h2>Swap</h2>
        <span class="sw__chip">Slippage 0.5%</span>
      </header>

      <div class="sw__panels">
        <div class="sw__panel" data-panel="pay">
          <div class="sw__top"><label for="sw-pay">You pay</label><span>Balance <b data-bal="pay"></b></span></div>
          <div class="sw__row">
            <input class="sw__amount" id="sw-pay" data-pay type="text" inputmode="decimal" autocomplete="off" spellcheck="false" maxlength="9">
            <span class="sw__token" data-token="pay"><i></i><b></b></span>
          </div>
        </div>
        <button class="sw__flip" type="button" data-flip aria-label="Switch the two tokens">
          <svg viewBox="0 0 18 18" aria-hidden="true"><path d="M6 3.500v11M6 14.500l-3-3M6 14.500l3-3M12 14.500v-11M12 3.500l-3 3M12 3.500l3 3"></path></svg>
        </button>
        <div class="sw__panel" data-panel="get">
          <div class="sw__top"><span>You receive</span><span>Balance <b data-bal="get"></b></span></div>
          <div class="sw__row">
            <output class="sw__amount" data-get for="sw-pay"></output>
            <span class="sw__token" data-token="get"><i></i><b></b></span>
          </div>
        </div>
      </div>

      <p class="sw__rate"><span class="sw__ratein"><span data-rate></span></span><span class="sw__fee">Fee $1.20</span></p>

      <button class="sw__go" type="button" data-go>
        <span class="sw__gofill" data-gofill aria-hidden="true"></span>
        <span class="sw__golabel"><svg viewBox="0 0 16 16" aria-hidden="true"><path data-gotick pathLength="1" d="M3.500 8.500l3 3 6-6.500"></path></svg><span data-golabel>Swap</span></span>
      </button>
      <span class="sw__say" data-say aria-live="polite"></span>
    </section>

    <svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.200 19.200 11l-6.300 1.600-3.300 5.900Z"></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.

18 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 “Crypto swap card” 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 ground with a lime glow at the top, a dark card: “Swap” and the chip “Slippage 0.5%”. Two panels one above the other: “You pay” with the amount 0.5 and the ETH pill, “You receive” with 1,612.40 and the USDC pill, each with its balance; between the two, straddling them, a disc with two arrows. Below, “1 ETH = 3,224.80 USDC”, the fee and the lime “Swap” button. Type 1.25 in the first field and the second counts up to 4,031.00. Press the disc and it makes a half turn, the two pills cross, one bending left and one right, the amounts change panel, the balances swap and the rate line rolls into “1 USDC = 0.00031 ETH”. Press Swap and the button gives, says “Swapping” while a light runs through it, then “Swapped” with a tick drawing itself; the two panels glow lime for a moment and the balances count to their new values. With an amount above the balance the button goes dim and says “Not enough ETH”.

How it works

The counting amount

At every key the amount received is worked out and a tween takes a number there, rewriting the text at each step with thousands separators.

Trading places

First the data swap and the two pills are rewritten; then each starts from the other’s position (the distance is measured) and goes back to zero, with an x that goes out and back at half time to make the arc.

The half turn

The disc’s angle grows by 180 degrees at every switch and never goes back: the pivot is the button’s centre.

The confirmation

A band with scaleX from 0 to 1 crosses the button; at the end the tick draws, its width goes from 0 to 16 pixels and the two balances count on the same tween.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#b6f24aThe colour of the Swap button, the text cursor and the active field’s edge.
PRICEscript.js3224.8How many USDC one ETH is worth: the amount received and the rate line come from here.
FLIP_TIMEscript.js0.7How many seconds the two tokens take to trade places.
SPRINGscript.js1How much the disc bounces as it turns: 0.3 = a little, 2 = a lot.
LOOPscript.jstrueLeft alone, the demo’s pointer types an amount, switches the tokens and confirms.

Try them in the Playground

When to use it

On the swap screen of a wallet or an exchange, in a converter between two currencies or two units, wherever two linked fields can be switched round.

On phones

It is made for the phone: the card is 316 pixels wide at most, the field opens the number keyboard (inputmode decimal) and the switch disc is 38 pixels wide with an edge that sets it apart.

With reduced motion

Amounts, tokens, balances and rate change at once, with no counting, arcs or half turn; Swap says “Swapping” then “Swapped” without the light. The demo does not move by itself.

Pitfalls

  • Tokens, balances, price and fee are made up and the discs carry a letter, not a logo: in a real app the rate comes from a service and changes as you watch. Nothing here is investment advice.
  • The field takes only digits and one point, with as many decimals as the token has; a comma becomes a point.
  • Money amounts are not computed with floating-point numbers in a real app: integers in the smallest unit are needed.
  • The pills move with GSAP’s x and y after the data have already swapped: so if the animation is interrupted, what you read is still right.
  • The aria-live region says who pays and who receives after the switch, and the outcome after Swap; while working the button has aria-disabled.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 22 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 animations