Skip to content
animorio
IT
All components

Poll with results

Ratings, HoverGSAP, CSS onlyEasyCompressed weight: Demo 6.0 KBGSAP 28 KBFreeDownload the zip

A poll card in a community, on very light grey: a question and four answers in whole rows. Pick one and every row becomes a bar that fills from the left to its share on a spring, the percentages roll, the pick gets a drawn tick and the purple border, the most voted turns bold and the total grows by one; Change vote takes it all back.

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>
<!--
  "Poll with results" 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 poll that reveals its results</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 poll in a community app: four answers in whole rows. Pick one and every row becomes a bar that fills to its
         share on a spring, the percentages roll, the pick gets a drawn tick and the accent border, the leader turns
         bold and the total grows by one. Change vote runs it back -->
    <section class="card" data-card aria-labelledby="q">
      <header class="card__top">
        <span class="badge" aria-hidden="true">D</span>
        <div class="who">
          <span class="who__name">Driftline</span>
          <span class="who__meta">Poll from <b>Mara Ilves</b> · 3h</span>
        </div>
      </header>

      <h1 class="q" id="q" data-question>Where do you prototype first?</h1>

      <div class="opts" role="radiogroup" aria-labelledby="q" data-opts>
        <button class="opt" type="button" role="radio" aria-checked="false" data-opt="0">
          <span class="opt__fill" data-fill></span>
          <span class="opt__row">
            <span class="opt__label">Paper sketches</span>
            <svg class="opt__tick" viewBox="0 0 24 24" aria-hidden="true"><path d="M5.5 12.6l4.1 4 8.9-9.2"></path></svg>
            <span class="opt__pct" data-pct aria-hidden="true"></span>
          </span>
        </button>
        <button class="opt" type="button" role="radio" aria-checked="false" data-opt="1">
          <span class="opt__fill" data-fill></span>
          <span class="opt__row">
            <span class="opt__label">In the design tool</span>
            <svg class="opt__tick" viewBox="0 0 24 24" aria-hidden="true"><path d="M5.5 12.6l4.1 4 8.9-9.2"></path></svg>
            <span class="opt__pct" data-pct aria-hidden="true"></span>
          </span>
        </button>
        <button class="opt" type="button" role="radio" aria-checked="false" data-opt="2">
          <span class="opt__fill" data-fill></span>
          <span class="opt__row">
            <span class="opt__label">Straight in code</span>
            <svg class="opt__tick" viewBox="0 0 24 24" aria-hidden="true"><path d="M5.5 12.6l4.1 4 8.9-9.2"></path></svg>
            <span class="opt__pct" data-pct aria-hidden="true"></span>
          </span>
        </button>
        <button class="opt" type="button" role="radio" aria-checked="false" data-opt="3">
          <span class="opt__fill" data-fill></span>
          <span class="opt__row">
            <span class="opt__label">On a whiteboard</span>
            <svg class="opt__tick" viewBox="0 0 24 24" aria-hidden="true"><path d="M5.5 12.6l4.1 4 8.9-9.2"></path></svg>
            <span class="opt__pct" data-pct aria-hidden="true"></span>
          </span>
        </button>
      </div>

      <footer class="card__foot">
        <p class="total" aria-live="polite"><span data-total>1,284</span> votes · <span data-days>2 days left</span></p>
        <button class="change" type="button" data-change tabindex="-1">Change vote</button>
      </footer>
    </section>

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

31 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 “Poll with results” 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 a very light grey, in the middle, a white card from the made up Driftline community: the purple square mark with a D, the name, “Poll from Mara Ilves · 3h”, then the question “Where do you prototype first?” and four answers in rounded grey rows, with no dots in front. Hovered, a row darkens slightly; pressed, it squeezes a touch. Pick an answer and all four become lilac bars filling from the left to their share on a spring that goes a hair past and back, one after the other; on the right the percentages roll in digit by digit. The picked row gets the purple border with a soft halo, the stronger bar and a tick drawn next to the number; the most voted answer turns bold with Mona Sans’s variable weight. Below, “1,284 votes” becomes 1,285 with the last digit rolling, and Change vote appears, which empties the bars, removes the tick and brings the total back. A drawn pointer hovers one answer, votes for another, changes its vote and votes again.

How it works

Whole rows, no marks

Each answer is a button with role radio inside a radiogroup: the whole row is clickable and the arrows move between them. The bar is a full size child with scaleX from 0 to its share and transform-origin on the left, so GSAP moves the bar and CSS keeps the row’s border and background still.

Shares that always make a hundred

The percentages use the largest remainder method: everything is rounded down and the missing points go to the highest remainders, so the four figures always add up to 100, even after your vote.

Rolling digits

Each digit is a column from 0 to 9 inside a window one line tall; GSAP moves the column with yPercent, starting from zero for the percentages and from the previous digit for the total, so only the last one moves in the total.

The vote’s choreography

The bars start 60 thousandths apart with back.out, the percentages come in with them, the tick is drawn with stroke-dashoffset, the leader’s bold arrives halfway through the fill with a transition of the variable font’s weight, and Change vote appears last.

Values to change

NameFileDefaultWhat it changes
QUESTIONscript.jsWhere do you prototype first?The poll’s question.
VOTESscript.js231, 591, 347, 115The votes of the four answers before yours.
DAYS_LEFTscript.js2How many days the poll has left.
FILL_TIMEscript.js0.9How long the bars take to fill, in seconds.
BOUNCEscript.js1.15How far the bar goes past and comes back.
STAGGERscript.js0.06The delay between one bar and the next.
ACCENTscript.js#6d5efcThe colour of the pick, the tick and the border.

Try them in the Playground

When to use it

For polls in a community, a social app, a newsletter or a team tool, to ask for an opinion inside an article or for quick votes in an app.

On phones

The card takes the width with a margin, rows and type are sized on the height too with clamp and min, so the four bars, the total and Change vote fit in the box. A tap votes like a click.

With reduced motion

No springs or rolling: the bars fade in already at their share, the percentages show their number at once and the tick appears.

Pitfalls

  • Rounding every share on its own can add up to 99 or 101: the largest remainder method is needed.
  • The bar is animated with scaleX on a full size child, not with width: that way the layout is not worked out again on every frame and the text on top does not move.
  • The fake pointer’s hover cannot use :hover: an is-hover class is added, and the real :hover sits inside @media (hover: hover) so it does not stay on after a tap on iPhone.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 25 October 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