Skip to content
animorio
IT
All components

Quiz question card

Games, Hover, SVGGSAP, CSS onlyMediumCompressed weight: Demo 5.4 KBGSAP 28 KBFreeDownload the zip

One question of a quiz with four answers. Choosing one, the right one lights up green with its tick; if you were wrong, yours shakes and turns red with a cross. Every answer fills with the share of people who picked it, the streak of right answers goes up or back to zero and a line explains why.

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>
<!--
  "Quiz question card" 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>Quiz question with the answer that reveals itself and the streak that climbs</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">
    <!-- one question of a quiz: four answers; choosing one reveals the right one in green with its tick, a wrong
         choice shakes and turns red, every answer fills with the share of people who picked it, the streak rolls up
         or falls back to zero and a line explains the answer -->
    <section class="quiz" data-quiz aria-label="Quiz question">
      <header class="top">
        <div class="steps" aria-hidden="true"><i class="is-done"></i><i class="is-done"></i><i data-step></i><i></i><i></i></div>
        <p class="streak" data-streak-box><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M8.6 1.4 3.4 9h3.8l-.8 5.6L11.6 7H7.8Z"></path></svg><span class="streak__n"><span data-streak>2</span></span><span class="streak__l">in a row</span></p>
      </header>

      <h1 class="ask">Which planet has the longest day?</h1>

      <div class="answers" role="group" aria-label="Answers">
        <button class="answer" type="button" data-answer data-share="0.18"><span class="answer__bar" data-bar></span><span class="answer__name">Mars</span><span class="answer__mark"><svg viewBox="0 0 24 24" aria-hidden="true"><path data-mark pathLength="1" d="M7 7l10 10M17 7 7 17"></path></svg></span><span class="answer__pct" data-pct>18%</span></button>
        <button class="answer" type="button" data-answer data-share="0.41" data-right><span class="answer__bar" data-bar></span><span class="answer__name">Venus</span><span class="answer__mark"><svg viewBox="0 0 24 24" aria-hidden="true"><path data-mark pathLength="1" d="M6.4 12.6 10.4 16.6 17.8 8"></path></svg></span><span class="answer__pct" data-pct>41%</span></button>
        <button class="answer" type="button" data-answer data-share="0.29"><span class="answer__bar" data-bar></span><span class="answer__name">Jupiter</span><span class="answer__mark"><svg viewBox="0 0 24 24" aria-hidden="true"><path data-mark pathLength="1" d="M7 7l10 10M17 7 7 17"></path></svg></span><span class="answer__pct" data-pct>29%</span></button>
        <button class="answer" type="button" data-answer data-share="0.12"><span class="answer__bar" data-bar></span><span class="answer__name">Mercury</span><span class="answer__mark"><svg viewBox="0 0 24 24" aria-hidden="true"><path data-mark pathLength="1" d="M7 7l10 10M17 7 7 17"></path></svg></span><span class="answer__pct" data-pct>12%</span></button>
      </div>

      <p class="why"><span data-why>Pick an answer</span></p>
    </section>
    <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.

26 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 “Quiz question card” 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

In the middle, on white, a light card. At the top five dashes say how far into the quiz you are, two already violet, and on the right a pill with a lightning bolt and ‘2 in a row’. Below the question, ‘Which planet has the longest day?’, and four answers one under the other: Mars, Venus, Jupiter, Mercury. Hovering an answer its edge turns violet. Tapping Venus the answer gives a small elastic kick, its edge and text turn green, a tick draws itself on the right and inside every answer a bar grows from the left with the share of people who chose it, with the percentage appearing: 41% for Venus, in green, the others in grey. The streak rolls to 3 and its pill jolts, the third dash fills with violet and below a line explains that a day on Venus lasts 243 Earth days. If you tap Jupiter instead, the answer shakes left and right, turns red with a cross, a moment later Venus lights up green, the streak drops to 0 and its pill turns grey, and the dash fills with red. Left alone, a pointer hesitates on one answer, picks the right one, and on the next round gets it wrong.

How it works

Real answers

Each answer is a button with data-share (the share of people who chose it) and, on the right one, data-right. After the choice the buttons are disabled and the card takes the is-over class.

Right and wrong

choose puts is-right on the right answer and, if needed, is-wrong on the chosen one: colours and edges are in the CSS. The tick and the cross are SVG paths drawn with stroke-dashoffset; the cross at once, the right answer’s tick three tenths later.

The shares

Inside every answer a bar scales horizontally to its share with elastic.out, one after the other, and the percentage appears: after answering you see what the others chose.

The shake

The wrong answer moves SHAKE pixels left, right, half left and returns on a spring: four steps in half a second.

The streak and the dash

The streak number rolls up if it rises and down if it drops to zero; this question’s dash fills through a CSS variable, violet or red.

Values to change

NameFileDefaultWhat it changes
STREAKscript.js2The right answers in a row before this question.
RIGHTscript.jsA day on Venus lasts 243 Earth days, longer than its year.The explanation after the right answer.
WRONGscript.jsIt is Venus: one day there lasts 243 Earth days.The explanation after a wrong answer.
SPRINGscript.js0.8How long the spring of the percentage bars lasts, in seconds.
STAGGERscript.js0.06The delay between one answer and the next, in seconds.
SHAKEscript.js6By how many pixels the wrong answer shakes.
HOLDscript.js2.8By itself: how many seconds the revealed answer stays.
LOOPscript.jstrueLeft alone, a pointer answers: once right, once wrong.

Try them in the Playground

When to use it

For a learning app, an online course, the quiz of a blog or a newsletter, a prize game for an event or a shop. With a single question it also suits a landing page, to let people try the product before signing up.

On phones

The same card, as wide as the screen: the answers are 44 pixels tall, comfortable for a finger, and on a short screen they tighten slightly.

With reduced motion

No shake and no springs: the colours change with a fade, the bars and marks appear at once and the numbers change with a fade.

Pitfalls

  • Right and wrong are not told by colour alone: there are the tick, the cross and a line of text, also for screen reader users.
  • A disabled button takes the browser’s grey: the text colour must be set in the CSS, or the right answer looks dimmed.
  • The shares must add up to 100: here they are 18, 41, 29 and 12.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 5.4 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 components