Skip to content
animorio
IT
All components

Exam timer

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

The timer of an online exam: the time left in large rolling digits, the twenty questions as a row of segments (done, flagged, the current one) and the “Next question” and “Flag” buttons. In the last minute everything turns orange and the “Last minute” label appears; once the questions are done the button becomes “Hand in exam”, and on handing in the timer stops, turns green and says how much time was to spare.

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>
<!--
  "Exam timer" 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>Exam timer</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 timer of an online exam: the time left counting down, the questions answered and flagged,
         the last minute changing colour, and handing in with the tick -->
    <section class="ex" data-ex data-state="run" aria-label="Exam timer">
      <header class="ex__head">
        <span class="ex__course">Biology 201 · Midterm</span>
        <span class="ex__badge" data-badge aria-hidden="true"><svg viewBox="0 0 14 14"><circle cx="7" cy="7" r="5.200"></circle><path d="M7 4.300V7l1.900 1.300"></path></svg>Last minute</span>
      </header>
      <div class="ex__clock" data-clock role="timer" aria-label="Time left">
        <span class="ex__d"><span data-outd>0</span></span><span class="ex__d"><span data-outd>1</span></span><span class="ex__colon" aria-hidden="true">:</span><span class="ex__d"><span data-outd>0</span></span><span class="ex__d"><span data-outd>8</span></span>
      </div>
      <p class="ex__sub"><span data-outsub>Time left</span></p>
      <div class="ex__qs" data-qs aria-hidden="true"></div>
      <div class="ex__meta">
        <span class="ex__count"><span data-outcount>17 of 20 answered</span></span>
        <span class="ex__flags"><svg viewBox="0 0 14 14" aria-hidden="true"><path d="M3.500 12.300V2.200M3.500 2.800h6.600l-1.500 2.400 1.500 2.400H3.500"></path></svg><span data-outflags>1 flagged</span></span>
      </div>
      <div class="ex__actions">
        <button class="ex__main" type="button" data-next><span class="ex__face" data-face="next">Next question</span><span class="ex__face" data-face="hand">Hand in exam</span><span class="ex__face" data-face="busy">Handing in</span><span class="ex__face" data-face="done"><svg viewBox="0 0 16 16" aria-hidden="true"><path data-tick pathLength="1" d="m3.600 8.400 2.900 2.900 5.900-6.600"></path></svg>Handed in</span></button>
        <button class="ex__flag" type="button" data-flag aria-pressed="false"><svg viewBox="0 0 14 14" aria-hidden="true"><path d="M3.500 12.300V2.200M3.500 2.800h6.600l-1.500 2.400 1.500 2.400H3.500"></path></svg>Flag</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.

26 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 “Exam timer” 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 “Biology 201 · Midterm”, below it the time left in large digits, “01:08”, going down one second at a time with the changing digit rolling, and the line “Time left”. Then the twenty questions as a row of segments: dark for done, orange for the flagged one, taller and lighter for the current one; below, “17 of 20 answered” and “1 flagged”. At the bottom the dark “Next question” button and the outlined “Flag”. “Next question” closes the current question: its segment jumps and turns dark, the next one rises, the count rolls. “Flag” marks the current question in orange. When the time drops to one minute the card, the edge and the digits turn orange, the digits take a small breath, the “Last minute” label lands top right and the line says “Check your flagged answers”. With the questions done the button becomes “Hand in exam”: on tap it says “Handing in”, then the timer stops, everything turns green, the tick draws itself next to “Handed in”, the segments do a wave and the line says how much time was to spare. If the time reaches zero the exam hands itself in.

How it works

Time is read, not counted

On every frame the time left is the start minus the seconds elapsed on GSAP’s clock: no counter going down by one, so it never falls behind when the browser tab sleeps. The page is touched only when the second changes.

Only the changing digit rolls

The four digits are four equal-width cells, each with its own window. The new text is compared with the one in place: only what changes rolls, nearly always the last digit, and every ten seconds the one before it.

One attribute for the colour

Running, last minute and handed in are one attribute on the card that changes a single variable: the ground, the edge, the shadow, the digits and the current question all take their colour from it.

The questions in a row

The twenty segments are written by the script. On every change they get three classes (done, current, flagged) and a spring on their height: the one just closed jumps and settles, the new one rises.

Values to change

NameFileDefaultWhat it changes
WARNscript.js#d9770bThe colour of the last minute and of the flagged questions.
GOODscript.js#128a5eThe colour of the handed-in exam.
STARTscript.js68How many seconds are left when the timer starts.
LASTscript.js60Below how many seconds the last-minute warning starts.
SPEEDscript.js1How many timer seconds pass in one real second.
SPRINGscript.js1How much digits, segments and buttons bounce.
LOOPscript.jstrueLeft alone, the demo’s pointer answers, hands in and then starts again.

Try them in the Playground

When to use it

At the top of the page of a timed exam, test or quiz of an online school or a university; the same timer with its final warning carries a hiring assessment, a language test, an auction about to close or a basket held for a few minutes.

On phones

The card is at most 336 pixels wide and about 270 tall, and narrows with the screen: the question segments share the room by themselves. The two buttons are 46 pixels tall; on a very short screen the digits get smaller.

With reduced motion

The timer still counts, but digits and texts change without rolling, the segments change colour without jumping and the last-minute label fades in. The tick is already drawn. The demo’s pointer does not start.

Pitfalls

  • A timer that takes one second off per tick falls behind when the tab is in the background: here the time left is recomputed from the clock every time. In a real exam the end time comes from the server, which also decides the hand-in when time runs out.
  • The digits are tabular and every cell has a fixed width: without it, “1” and “8” shift the whole time every second.
  • The last minute is not told by colour alone: the label and the sentence appear, and an aria-live region announces it once (not every second).
  • During the hand-in the buttons are really disabled, so a double tap cannot hand in twice.
  • Course, questions and times are invented.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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