Skip to content
animorio
IT
Back to the library

Colour keyboard

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

The accent colour panel of a made-up design app, Tintwell: ten colours under glass keys, like a small mechanical keyboard. As the pointer passes, the key sinks on a real spring, its neighbours dip a little with it and a streak of light crosses the glass; meanwhile the preview above floods with that colour in a circle starting from the side of the key, and the button, the word in the headline and the chart bars take it on. The name rolls in, the hex code changes letter by letter, and a click applies the colour.

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>
<!--
  "Colour keyboard" 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 colour keyboard with glass keys that press down on hover</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 accent panel of a made-up design app, Tintwell. Ten colours sit under glass keycaps: passing over a key
         presses it down like a mechanical key, on a spring, and the preview above floods with that colour from the
         side of the key. Clicking a key applies the colour; leaving the keyboard brings back the applied one -->
    <section class="panel" data-panel aria-label="Tintwell accent colour">
      <span class="panel__sheen" aria-hidden="true"></span>

      <header class="head">
        <span class="brand">
          <svg class="brand__mark" viewBox="0 0 20 20" aria-hidden="true">
            <circle cx="7.5" cy="8" r="4.6" />
            <circle cx="12.5" cy="8" r="4.6" />
            <circle cx="10" cy="12.4" r="4.6" />
          </svg>
          <span class="brand__name">Tintwell</span>
        </span>
        <span class="head__label">Accent colour</span>
        <span class="applied" data-applied aria-live="polite">
          <svg class="applied__tick" viewBox="0 0 16 16" aria-hidden="true"><path data-tick d="M3.6 8.4l2.8 2.8 6-6.2" pathLength="1" /></svg>
          <span data-applied-text>Applied</span>
        </span>
      </header>

      <div class="preview" data-preview aria-hidden="true">
        <span class="preview__tint" data-tint></span>
        <span class="preview__flood" data-flood></span>
        <div class="mock">
          <div class="mock__bar"><span></span><span></span><span></span><i></i></div>
          <div class="mock__body">
            <div class="mock__text">
              <b class="mock__title">Ship the <em>spring</em> palette</b>
              <span class="mock__line"></span>
              <span class="mock__line mock__line--short"></span>
              <span class="mock__button">Get started</span>
            </div>
            <div class="mock__chart">
              <span style="--h: .42"></span><span style="--h: .68"></span><span style="--h: .5"></span><span style="--h: .86"></span><span style="--h: .62"></span>
            </div>
          </div>
        </div>
      </div>

      <div class="readout">
        <span class="readout__swatch" data-swatch></span>
        <span class="readout__name"><span data-name>Coral</span></span>
        <span class="readout__hex" data-hex>#FF6B4A</span>
        <span class="readout__hint" data-hint>Hover a key to preview, click to apply</span>
      </div>

      <div class="keys" data-keys role="radiogroup" aria-label="Accent colours"></div>
    </section>

    <svg class="pointer" data-pointer viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.5 18.5 12 12.4 13.6 9.4 19.6z" /></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.

24 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 “Colour keyboard” 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 warm paper sits the white panel of Tintwell, a made-up design app, with soft corners, an edge that catches the light and a layered shadow. At the top the brand (three outlined circles) and the «Applied» pill with the tick in the chosen colour. Below it the preview: a slice of a product page with a headline, two lines, a button and a bar chart, on a ground faintly tinted by the accent. Under it the colour name, its hex code and, at the bottom, ten glass keys on a darker base: inside each one is its colour, like a well of enamel, with the name engraved. Passing over a key, it sinks a few pixels on a real spring, computed every frame: it goes a hair too far and settles; the keys next to it dip a little with it and a streak of light crosses its glass. Meanwhile the preview floods with the new colour in a circle starting from the side of the key, the button, the word «spring» and the bars take the colour, the name rolls in the direction you move and the changing letters of the code rise one after the other. A click applies the colour: the key stays a little low with a dark ring, the pill redraws its tick and says the name; leaving the keyboard brings back the applied colour. It also works with the arrow keys. Left alone, a drawn pointer passes over the keys and picks two.

How it works

One key, three layers

Each key is a button with a still dark base, which shows the travel, and a glass cap on top: inside the cap a well with the colour in a radial gradient, a glass veil with a fixed highlight and a streak of light that slides when the key is pressed. Each key's colour is a CSS variable, --c.

A spring for every key

Each key has a position and a velocity. Every frame, in three small steps, the acceleration is the stiffness times the distance to the target minus the damping times the velocity: the target is DEPTH under the pointer, a share of DEPTH for the neighbours in the row and the column, a third for the applied key. With little damping the key goes a hair too far and comes back.

The colour flooding the preview

Over the preview's tinted ground sits a second ground in the new colour, cut by a circular clip-path. The circle's centre is under the preview, level with the key; the radius goes from zero to the distance to the farthest corner. At the end the new colour becomes the ground and the circle closes unseen. Meanwhile GSAP takes the --accent variable to the new colour, and the button, the headline word and the bars follow it.

The name and the code

The name leaves upwards and the new one comes in from below with a small bounce (the other way round when you go back). The hex code is rebuilt letter by letter, and only the letters that change rise, one after the other.

Applying and going back

A click applies the colour: the key gets a dark ring, receives an upward push that the spring brings back down, and the pill redraws its tick. Leaving the keyboard returns the preview to the applied colour. The arrow keys move the applied colour, and the keyboard is a radiogroup.

Values to change

NameFileDefaultWhat it changes
DEPTHscript.js5How many pixels the key under the pointer sinks.
NEIGHBOURscript.js0.22How much the neighbouring keys sink, as a share of DEPTH.
STIFFNESSscript.js520Stiffness of the key spring: higher, faster.
BOUNCEscript.js0.32How far the key overshoots coming back: 0 none, 1 a lot.
FLOODscript.js0.55Seconds for the colour to flood the preview.
ROLLscript.js0.32Seconds for the colour name to roll in.
LOOPscript.jstrueLeft alone, the drawn pointer plays it again.

Try them in the Playground

When to use it

For the theme or brand colour panel of a design app, a site builder or an editor; to pick the colour of a product in a shop; anywhere a choice between a few colours deserves a physical gesture and a preview that answers straight away.

On phones

The same animation with adapted sizes: the panel takes almost the whole width, the preview gets shorter with the screen height and the hint line disappears. With a finger a tap presses the key and applies the colour.

With reduced motion

The keys do not move and there is no streak of light: the preview colour arrives as a fade, the name and the code change without moving, and the self-running loop changes the applied colour at intervals.

Pitfalls

  • The key springs must be integrated in several small steps per frame: with a single step, at high stiffness, the spring goes unstable and the key jitters.
  • The clip-path circle must start under the preview and reach the farthest corner: with a fixed radius, a corner is left uncovered on wide previews.
  • When moving fast over several keys, the previous circle must be finished at once (progress(1)) before opening another, otherwise two colours fight over the ground.
  • The code digits must not use tabular-nums: with this typeface the zero comes out slashed, like a typewriter.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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