Skip to content
animorio
IT
All components

Chess clock

Timers, HoverGSAP, CSS onlyMediumCompressed weight: Demo 5.9 KBGSAP 28 KBFreeDownload the zip

A chess clock in a card on white: two halves, White and Black, each with its time in large figures and its move count. The dark ground sits under whoever is to move; a tap on your own half passes the turn: the ground slides across with a bounce, a green “+2” chip adds the increment and the other’s time starts going down. Under ten seconds the figures turn red with tenths; at zero the flag falls, the ground turns red and you read who wins on time.

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>
<!--
  "Chess clock" 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>Chess clock</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">
    <!-- a chess clock: two halves with each player's time, a tap on your own half to pass the turn, the dark
         ground sliding to the other side, the increment added and red tenths under ten seconds -->
    <section class="cc" data-cc aria-label="Chess clock">
      <header class="cc__head">
        <div class="cc__what"><strong>Chess clock</strong><span data-outmode>Bullet, 12 s and 2 s a move</span></div>
        <span class="cc__state"><span class="cc__clip"><span data-outstate>Paused</span></span></span>
      </header>

      <div class="cc__clock" data-clock>
        <span class="cc__thumb" data-thumb></span>
        <button type="button" class="cc__side" data-side aria-label="White, pass the turn"><span class="cc__name">White</span><span class="cc__time" role="timer"><b data-outtime>0:12</b></span><span class="cc__moves"><span class="cc__clip"><span data-outmoves>No moves yet</span></span></span><i class="cc__inc" data-inc>+2</i></button>
        <button type="button" class="cc__side" data-side aria-label="Black, pass the turn"><span class="cc__name">Black</span><span class="cc__time" role="timer"><b data-outtime>0:12</b></span><span class="cc__moves"><span class="cc__clip"><span data-outmoves>No moves yet</span></span></span><i class="cc__inc" data-inc>+2</i></button>
      </div>

      <div class="cc__row">
        <span class="cc__hint"><span class="cc__clip"><span data-outhint>Press play to start</span></span></span>
        <button type="button" class="cc__btn" data-play aria-label="Start the clock"><svg viewBox="0 0 16 16" aria-hidden="true"><path class="cc__ic-play" d="M5.200 3.400v9.200l7.400-4.600Z"></path><path class="cc__ic-pause" d="M5 3.500v9M11 3.500v9"></path></svg></button>
        <button type="button" class="cc__btn" data-reset aria-label="Reset the clock"><svg viewBox="0 0 16 16" aria-hidden="true" data-reseticon><path class="cc__ic-line" d="M3.200 8a4.800 4.800 0 1 0 1.500-3.500M3 2.600v2.600h2.600"></path></svg></button>
      </div>
    </section>
    <span class="live" aria-live="polite" data-live></span>

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

21 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 “Chess clock” 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 white, a rounded card: at the top “Chess clock”, “Bullet, 12 s and 2 s a move” and on the right the status pill, “Paused”. In the middle a pale grey panel split in two halves: “White” on the left and “Black” on the right, each with the time “0:12” in large narrow figures and below “No moves yet”. Under the half of whoever is to move there is a dark rounded ground, and there the figures are white. At the bottom a help line and two round keys: play and reset. Pressing play the icon becomes pause, the status rolls to “White to move” and White’s time goes down. Tapping the dark half, the ground slides under the other one with a bounce and squashes slightly, a green “+2” chip rises beside the mover’s time, the count becomes “1 move” and Black’s time starts going down. Tapping the pale half, which is not to move, makes it shake its head. Under ten seconds the figures turn red and show tenths, “0:07.4”. If a time reaches zero the clock gives a start, the ground turns red, the status says “Time” and the line below “White wins on time”. The reset key spins on itself and takes everything back to the start.

How it works

Two times, one turn

Each side’s seconds, the moves, whose turn it is, whether the clock runs and who ran out: only the time of the side to move goes down.

Passing the turn

The tap only counts on the half to move and with the clock running: it adds the increment to the mover, counts the move and changes turn.

A single ground

The dark ground is one element sliding between the two halves; its place is worked out from the panel’s width and worked out again on resize.

Tenths at the end

Above the threshold the time is written rounded up to the second; below it, with the tenths cut off: so zero only appears when it is really over.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#e0452fThe colour of time running out and of the fallen flag.
SECONDSscript.js12How many seconds each player has at the start.
INCscript.js2How many seconds are gained with every move.
LOWscript.js10Under how many seconds the time turns red and shows tenths.
LOOPscript.jstrueLeft alone, the demo’s pointer plays a few moves, pauses and resets.

Try them in the Playground

When to use it

On the site or in the app of a chess club, a tournament or a board game platform, and as a tool to keep open on the table; the same two-half clock carries the speaking turns of a debate, the times of a card game, the answers of a two-player quiz or two speakers’ minutes.

On phones

The card is at most 348 pixels wide and about 300 tall. The two halves are 130 pixels tall and half the panel wide, all tappable; under 350 pixels the figures go down to 38 pixels. The play and reset keys are 40-pixel circles.

With reduced motion

Time still runs, but the dark ground changes half in one step, without sliding or bouncing; no increment chip, no starts, texts change in one step. The demo’s pointer does not start.

Pitfalls

  • Whose turn it is is not told by the dark ground alone: the pill at the top writes it (“White to move”) and every move is announced to screen readers.
  • The time step is capped at a quarter of a second: coming back from another tab nobody loses ten seconds at once.
  • The ground measured with `getBoundingClientRect` during the card’s entrance (which is scaled) would end up a few pixels off: use `clientWidth`.
  • The reset key spins the whole `<svg>` with `transformOrigin: "50% 50%"`: `svgOrigin` only applies to elements inside an svg.
  • Twelve seconds each are there for the demo to show the end: a real game has sixty and up, and one knob changes it.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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