Skip to content
animorio
IT
All components

Lap stopwatch

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

The stopwatch of a clock app, on black: Start sets the time running with its hundredths, Lap drops the row of the lap just closed on top of the list and the others make room. A thin strip measures the lap in progress against the best one, the fastest lap turns green and the slowest red, and Reset takes everything back to zero.

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>
<!--
  "Lap stopwatch" 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>Lap stopwatch</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 stopwatch of a clock app: the time runs, Lap drops a new row on top of the list,
         the strip measures the lap against the best one and the fastest and slowest laps take a colour -->
    <section class="sw" data-sw aria-label="Stopwatch">
      <p class="sw__time" role="timer" aria-label="Elapsed time" data-time></p>
      <p class="sw__now"><span class="sw__nowname"><span data-lapname>Lap 1</span></span><span class="sw__nowtime" data-laptime></span></p>
      <div class="sw__strip" aria-hidden="true">
        <span class="sw__fill sw__fill--echo" data-echo></span>
        <span class="sw__fill" data-fill></span>
        <span class="sw__best" data-best></span>
      </div>
      <div class="sw__keys">
        <button class="sw__key" type="button" data-lap disabled><span class="sw__keytext"><span data-laplabel>Lap</span></span></button>
        <button class="sw__key sw__key--go" type="button" data-go><span class="sw__keytext"><span data-golabel>Start</span></span></button>
      </div>
      <ol class="sw__list" data-list aria-label="Laps"></ol>
      <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.

17 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 “Lap stopwatch” 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 black, a dark card with a thread of green light at the top. The time in large type, “00:00.00”, with fainter hundredths; under it “Lap 1” on the left and the time of the lap in progress on the right, then a thin strip. Two buttons, Lap and Start, and a ruled list still empty. With Start the button becomes Stop, in soft red, the digits run without trembling and the green strip grows. At every Lap the row of the closed lap drops from above on a spring, the others move down one place, the strip starts again leaving a shadow that fades, the big time gives a small jolt and “Lap 2” rolls in place of “Lap 1”. Next to each lap is the difference from the one before; from the second lap the fastest takes the green and the slowest the red, and a white notch on the strip marks the best: once past it the strip turns pale. With Stop the time halts and Lap becomes Reset, which runs the digits back to zero and takes the rows away one after the other.

How it works

The time is a single number

Start launches a linear tween on one number, the seconds gone by; Stop kills it. Everything else is drawn from it on every frame.

Digits in cells

Every digit sits in a fixed-width cell and is rewritten only when it changed: the time does not tremble and tabular figures are not needed.

The lap

Lap puts the new row on top: the old ones start one row higher and come back to their place on a spring, the new one drops in and gains opacity.

Best and worst

At every lap the lowest and the highest times are found and the two classes moved; the strip widens to the slowest lap and the notch marks the fastest.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#35d980The colour of Start, of the strip and of the fastest lap.
SLOWscript.js#ff6f61The colour of Stop and of the slowest lap.
ROWSscript.js3How many laps show in the list: 2 to 4.
DELTAscript.jstrueNext to each lap, the difference from the lap before.
SPRINGscript.js1How much the rows and the buttons bounce: 0.3 = a little, 2 = a lot.
LOOPscript.jstrueLeft alone, the demo’s pointer starts the time, marks three laps, stops and resets.

Try them in the Playground

When to use it

In a clock app, in a running, swimming or training app, in a timekeeper’s or a track’s panel, and anywhere split times are measured one after the other.

On phones

The same card, 276 pixels wide at most: the big time narrows with the width, the two buttons are 44 pixels tall and the list keeps three rows, so everything fits a short screen.

With reduced motion

The time still runs, because it is the data; no springs and no dropping rows: the laps appear in place, the button labels change at once and Reset zeroes in one step. The demo does not move by itself.

Pitfalls

  • The demo’s time comes from the GSAP tween: in a real app you store the starting instant (performance.now or the server clock) and compute the difference, so it stays right with the tab in the background too.
  • Mona Sans’ tabular figures have a slashed zero: that is why every digit has its own equal-width cell, instead of font-variant-numeric.
  • The time has role=timer and is not read at every hundredth; at every lap and every Stop a hidden aria-live line says the time.
  • The list keeps only the visible rows plus one: the other laps stay in the data, and in a real app the list scrolls.
  • With the fastest and the slowest lap tied the colour goes to the first one found: decide a rule if you need one.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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