Skip to content
animorio
IT
All components

Campaign card

Cards, Hover, TransitionsGSAP, CSS onlyMediumCompressed weight: Demo 9.2 KBGSAP 28 KBFreeDownload the zip

The card of an ad campaign in a marketing dashboard, alone on white: Winter launch by Northbay, a made-up outdoor clothing shop. The budget bar fills up to $1,240 of $2,000, clicks, CTR and CPC roll digit by digit, and the line of the last 24 hours of clicks draws itself and slides one hour at a time while the campaign is Live. The switch pauses it: the line stops, flattens and turns grey, the numbers freeze and the equalizer next to Live becomes a pause sign; switched back on, the line springs back. Hovering the line shows the point of that hour with its clicks. People were searching for “digital marketing”.

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>
<!--
  "Campaign 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>Campaign card</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 card of an ad campaign of a made-up outdoor shop, Northbay: the budget that fills, clicks, CTR and CPC that
         roll, the clicks of the last 24 hours that slide along live, and the Live / Paused switch that flattens it all -->
    <section class="card" data-card aria-labelledby="cp-title">
      <div class="card__in">

        <header class="head" data-part>
          <span class="brand" aria-hidden="true"><svg viewBox="0 0 20 20"><path d="M5 15V5.2l10 9.6V5"></path></svg></span>
          <div class="head__text">
            <h2 class="head__name" id="cp-title" data-name>Winter launch</h2>
            <p class="head__meta">Northbay &middot; Search &amp; social ads</p>
          </div>
          <div class="state">
            <span class="state__label" data-state-label aria-hidden="true">
              <svg class="eq" viewBox="0 0 12 12" aria-hidden="true"><rect data-bar x="1.5" y="2" width="2" height="8" rx="1"></rect><rect data-bar x="5" y="2" width="2" height="8" rx="1"></rect><rect data-bar x="8.5" y="2" width="2" height="8" rx="1"></rect></svg>
              <span class="state__word" data-state-word>Live</span>
            </span>
            <button class="switch" type="button" role="switch" aria-checked="true" aria-label="Campaign running" data-switch>
              <span class="switch__track" data-track></span>
              <span class="switch__knob" data-knob></span>
            </button>
          </div>
        </header>

        <div class="budget" data-part>
          <div class="budget__row">
            <span class="label">Budget spent</span>
            <span class="budget__nums"><span class="roll roll--strong" data-spent></span><span class="budget__of">&nbsp;of <span data-total>$2,000</span></span></span>
          </div>
          <div class="bar" data-bar-box>
            <span class="bar__fill" data-fill><span class="bar__sheen" data-sheen></span></span>
            <span class="bar__tick" style="left:25%"></span><span class="bar__tick" style="left:50%"></span><span class="bar__tick" style="left:75%"></span>
          </div>
          <div class="budget__row budget__row--small">
            <span class="roll" data-pct></span>
            <span data-left-line>Ends Dec 15</span>
          </div>
        </div>

        <dl class="stats" data-part>
          <div class="stat"><dt class="label">Clicks</dt><dd class="roll roll--big" data-clicks></dd></div>
          <div class="stat"><dt class="label">CTR</dt><dd class="roll roll--big" data-ctr></dd></div>
          <div class="stat"><dt class="label">CPC</dt><dd class="roll roll--big" data-cpc></dd></div>
        </dl>

        <figure class="chart" data-part>
          <figcaption class="chart__cap"><span class="label">Clicks &middot; last 24 hours</span><span class="chart__hint" data-hint>per hour</span></figcaption>
          <div class="chart__box" data-chart>
            <svg class="chart__svg" data-svg aria-hidden="true">
              <defs>
                <linearGradient id="cp-area" x1="0" y1="0" x2="0" y2="1">
                  <stop offset="0" stop-color="var(--accento)" stop-opacity="0.2"></stop>
                  <stop offset="1" stop-color="var(--accento)" stop-opacity="0"></stop>
                </linearGradient>
                <clipPath id="cp-clip"><rect data-clip x="0" y="0" width="0" height="400"></rect></clipPath>
              </defs>
              <line class="chart__base" data-base x1="0" x2="0" y1="0" y2="0"></line>
              <line class="chart__mid" data-mid x1="0" x2="0" y1="0" y2="0"></line>
              <g clip-path="url(#cp-clip)">
                <path class="chart__area" data-area fill="url(#cp-area)"></path>
                <path class="chart__line" data-line></path>
              </g>
              <line class="chart__cursor" data-cursor x1="0" x2="0" y1="0" y2="0"></line>
              <circle class="chart__ring" data-ring r="4" cx="0" cy="0"></circle>
            </svg>
            <div class="tip" data-tip aria-hidden="true"><span class="tip__time" data-tip-time>10:00</span><span class="tip__val" data-tip-val>41 clicks</span></div>
          </div>
          <div class="chart__axis"><span data-axis-start>24h ago</span><span>Now</span></div>
        </figure>
      </div>
    </section>
    <p class="sr" aria-live="polite" data-live></p>
  </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.

36 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 “Campaign 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

On a white background, a white card with a soft layered shadow and a thread of light along the top edge. At the top the light violet tile with Northbay's line mark, the campaign name, Winter launch, and “Search & social ads”; on the right the word Live in violet with a small three-bar equalizer whose bars move on their own, and the violet switch. Below, Budget spent with $1,240 of $2,000 and the bar filling from the left with a violet gradient, three thin ticks at the quarters and a glint running along it with every new hour; under it, 62% used and Ends Dec 15. Then three numbers split by thin lines, Clicks, CTR and CPC, rolling digit by digit to their values as the card opens. At the bottom the soft line of the last 24 hours of clicks, with a fading area under it, drawing itself from the left; while the campaign is Live a new hour arrives every 1.4 seconds: the line slides one step left, clicks and spend roll up and the CTR moves by a hundredth. On hover (or with a finger) a dashed vertical line and a white ring follow the nearest point, with a dark label giving the hour and its clicks. Tapping the switch stretches the knob while pressed and slides it left on a spring, the track turns grey, Live becomes Paused, the equalizer stops and becomes a pause sign, the line flattens towards its average and turns grey, the bar loses its colour and the numbers stand still. Switched back on, the line springs back up on an elastic and the hours start arriving again.

How it works

A line redrawn every frame

The line is an SVG path rebuilt from an array of 24 hourly values: each point becomes a cubic Bézier curve with Catmull-Rom control points (a sixth of the distance between neighbours), and the area under it is the same path closed at the bottom. The viewBox matches the box in pixels and is remeasured on resize, so the stroke stays 1.8 pixels at any width.

The new hour coming in from the right

Each hour a value is pushed at the end of the array and GSAP takes a shift from 0 to 1: every point is drawn at (i − shift) times the step, so the whole line slides one step and the new point enters from the right; at the end the first value is dropped and the shift goes back to 0, with no jump.

Flattening without changing the data

Each value is drawn as mean + (value − mean) × amplitude. When paused GSAP takes the amplitude to FLATTEN with power3.inOut and the line lies down towards its average; switched on it goes back to 1 with elastic.out, overshooting and bouncing. The data stay true: the hover label always gives the hour's real clicks.

Rolling digits

Spend, percentage, clicks, CTR and CPC are built digit by digit: every digit is a column from 0 to 9 in a window one line tall, with tabular-nums, and GSAP takes it to yPercent −10 times the digit, staggered from the right like an odometer.

The switch and the equalizer

It is a button with role switch and aria-checked. Pressed, the knob widens from 18 to 22 pixels towards the middle; released, it slides on back.out. The three bars next to Live swing in scaleY with different durations; when paused the middle one fades and the outer two stretch and move a pixel and a half closer, becoming a pause sign.

Values to change

NameFileDefaultWhat it changes
CAMPAIGNscript.jsWinter launchThe campaign name.
BUDGETscript.js2000The total budget, in dollars.
SPENTscript.js1240How much has been spent when the card opens.
CLICKSscript.js8412The campaign's clicks so far.
CTRscript.js3.84The CTR, as a percentage.
LIVE_TICKscript.js1.4How many seconds between new hours of clicks.
FLATTENscript.js0.08How much shape the line keeps when paused (0 = flat).
BOUNCEscript.js0.38The line's spring when it restarts (lower, more bounces).
ROLL_TIMEscript.js0.7How long the digits take to roll.
LOOP_PAUSEscript.js2The pause at the end of the self-running loop.

Try them in the Playground

When to use it

In the dashboard of a digital marketing or online advertising tool, in the back office of a shop that runs campaigns, in an app that manages social ads, or on a SaaS product page showing how budget and clicks are watched.

On phones

The card takes the width with a margin and its spacing and chart height also follow the height with clamp, so it all fits the phone preview box; the line is remeasured on resize even mid-animation. The finger does what hover does: tapping or dragging on the chart shows the point with its label, which goes away shortly after the finger lifts.

With reduced motion

No sliding or springs: the card shows the Live campaign straight away with the line already drawn and the numbers in place, new hours do not arrive and the self-running loop does not start. The switch works: the line flattens at once and the colours cross-fade.

Pitfalls

  • The Catmull-Rom curve on the lowest points dipped below the bottom of the chart: every y is clamped inside the box before the curve is built.
  • Dropping the first value mid-slide made the line jump a step: the value is dropped only when the shift reaches 1, together with the shift going back to 0.
  • Pausing while an hour was coming in left the line half a step off: the running slide is finished at once (progress 1) before flattening.
  • Scaling the budget bar with scaleX also squashed the glint running along it: the bar grows in width and the glint keeps its shape.
  • With a fixed viewBox the line's stroke got thicker or thinner as the box changed: the viewBox is remeasured in pixels on resize.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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