Skip to content
animorio
IT
Back to the library

API key rotation

Text, HoverGSAP, CSS onlyMediumCompressed weight: Demo 6.9 KBGSAP 28 KBFreeDownload the zip

The secret key card in the dashboard of a developer app, dark and product grade: pressing ‘Rotate key’ the characters after the prefix roll one after the other in a wave, like small counters, and land on the new key, blue for a moment, while a light runs under them and the line below says ‘Rotated just now’. Under the pointer the characters rise; the copy button turns its icon into a tick.

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>
<!--
  "API key rotation" 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 API secret key that rotates with characters rolling in a wave</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 secret key card of a developer dashboard: pressed Rotate key, the characters after the prefix roll one
         after the other in a wave, like small counters, and land on the new key while a light runs under them and
         the line below says it was rotated just now; under the pointer the characters rise; the copy button turns
         its icon into a tick -->
    <article class="card" data-card aria-label="Secret key, production">
      <header class="head">
        <span class="head__icon" aria-hidden="true"><svg viewBox="0 0 20 20"><circle cx="7" cy="13" r="3.4"></circle><path d="M9.5 10.5 16 4M13 7l2.2 2.2M11 9l1.6 1.6"></path></svg></span>
        <h1>Secret key</h1>
        <span class="head__env">Production</span>
      </header>

      <div class="well" data-well>
        <code class="key" data-key aria-label="Secret key"></code>
        <span class="well__light" data-light aria-hidden="true"></span>
        <button class="copy" type="button" data-copy aria-label="Copy the key">
          <svg viewBox="0 0 20 20" aria-hidden="true">
            <g data-copy-icon><rect x="7" y="7" width="9" height="9" rx="2.4"></rect><path d="M12.6 4H6.4A2.4 2.4 0 0 0 4 6.4v6.2"></path></g>
            <path class="copy__tick" data-copy-tick pathLength="1" d="M5 10.6 8.6 14.2 15.4 6.4"></path>
          </svg>
          <span class="copy__tip" data-copy-tip aria-hidden="true">Copied</span>
        </button>
      </div>

      <footer class="foot">
        <span class="foot__when"><span class="foot__roll"><span data-when>Created 14 March</span></span></span>
        <button class="rotate" type="button" data-rotate>
          <svg viewBox="0 0 20 20" aria-hidden="true" data-rotate-icon><path d="M15.6 8.2A6 6 0 0 0 4.9 6.6M4.4 11.8a6 6 0 0 0 10.7 1.6"></path><path d="M4.6 3.4v3.4H8M15.4 16.6v-3.4H12"></path></svg>
          Rotate key
        </button>
      </footer>
    </article>
    <p class="sr" data-live aria-live="polite"></p>

    <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.

19 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 “API key rotation” 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 with a blue haze at the top sits a dark card with round corners. At the top a tile with a drawn key, the title ‘Secret key’ and the ‘Production’ tag. Below, in a darker well, the key in fixed width characters: the prefix ‘sk_live_’ in grey and twenty light characters, and on the right the copy button. At the bottom ‘Created 14 March’ and the light ‘Rotate key’ pill. A pointer arrives on the pill, which widens a little, and presses it: the two arrows of the icon make a turn, and the key’s characters, from left to right, one after the other, leave upwards and come back from below four times with random letters, then land with a small bounce on the new character, blue, which goes back to light in a second. A blue light runs along the bottom of the well with the wave. The line below rolls to ‘Rotated just now’. Then the pointer runs along the key: the characters under it rise by a few pixels, the closest the most, and fall back. It reaches the copy button and presses it: the two sheets shrink, a blue tick draws itself in their place and the ‘Copied’ tag appears on the left, leaving after a moment. Left alone the card starts again with a different key every time; with a real hand the buttons answer every click and the characters follow the pointer or finger.

How it works

One cell per character

Each character is made of three spans: the outer one, 0.64 em wide, rises under the pointer; the middle one clips; the inner one is the only one GSAP moves. So the rise and the roll never fight over the same transform.

The roll

For each character a series of FLIPS rolls: it leaves upwards in 75 milliseconds, changes letter and comes back from below. The last roll brings the real character and lands with back.out. Each character starts WAVE seconds after the one before: that is the wave.

The colour that cools

While it rolls, the character is in the accent colour; once still a tween takes it back to light in 0.9 seconds and removes the inline colour. The light below is a radial glow crossing the well in the same time as the wave.

Invented keys

The keys come from a generator with a fixed seed and an alphabet without look-alike characters (0 and O, 1 and l): they are the same at every visit, and none is a real key.

The rise under the pointer

Every frame, for each cell the horizontal distance from the pointer is measured: within a little over three cells the wanted value is (1 minus distance) squared, and the cell chases it by 22% a frame. The transform is rewritten only if it changes.

Copy

The button writes the key to the clipboard where the browser allows it; the sheets icon shrinks, the tick draws itself with stroke-dashoffset and the ‘Copied’ tag comes in from the right with back.out, then everything goes back.

Values to change

NameFileDefaultWhat it changes
PREFIXscript.jssk_live_The part of the key that never changes.
LENGTHscript.js20How many characters change at each rotation.
ACCENTscript.js#5b8cffThe colour of the characters that just landed and of the light.
WAVEscript.js0.045How many seconds between one character and the next.
FLIPSscript.js4How many times each character rolls before it stops.
LIFTscript.js5By how many pixels the characters rise under the pointer.
LOOPscript.jstrueLeft alone, a pointer rotates it and copies it.

Try them in the Playground

When to use it

For the keys page in the settings of a developer app or a service with an API: the moment the old key is replaced can be seen, and is not mistaken for a plain page refresh. The same roll works for a recovery code, a discount code or a generated password.

On phones

The same animation with adapted sizes: the characters shrink with the screen width so the key stays on one line, and well and buttons also follow the window’s height. Dragging a finger along the key the characters rise.

With reduced motion

No rolling and no rising: the old key fades and the new one appears in its place, the line below changes in place and the copy tick appears without drawing.

Pitfalls

  • With a typeface that is not fixed width the key would jitter at every roll: each cell has its own width in em and the text centred.
  • The accent colour written inline during the roll must be removed at the end (clearProps), or the character stays off theme.
  • While the wave is rolling a second click would start two timelines on the same characters: until it is done, the button does not rotate again.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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