Skip to content
animorio
IT
All components

Train model button

Buttons, Hover, SVGGSAP, CSS onlyMediumCompressed weight: Demo 9.9 KBGSAP 28 KBFreeDownload the zip

The Train model button of a platform for training custom artificial intelligence models, a graphite pill on a near black page, like a Dribbble shot: on hover a dotted grid and the ghost of the last run appear inside it; pressed, it gives and springs back, and the training runs inside the button itself: the loss curve draws itself from the left and falls, with a mint area under it, a glow and a thin cursor at its head, the validation curve follows it dashed, one tick per epoch lights up on the bottom edge, the epoch number rolls and the loss counts down in the chip. At the end the curve flashes, a reflection crosses the pill, the icon turns into a check and the button says Model ready with the accuracy counting up.

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>
<!--
  "Train model button" 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 Train model button with the falling loss curve</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 Train model button of an AI platform for custom models, a dark graphite pill on a near black page. On hover
         a faint grid and the ghost of the last run show inside it; pressed, it gives under the finger and the training
         runs inside the button itself: the loss curve draws itself from left to right and falls, the validation curve
         follows it dashed, the epochs tick by on the bottom edge and the loss counts down in the chip. At the end the
         curve flashes, a reflection crosses the pill, a check draws itself and the button says Model ready -->
    <div class="tm" data-wrap>
      <span class="tm__floor" data-floor aria-hidden="true"></span>
      <button class="tm__btn" type="button" data-btn aria-label="Train model on 12k rows">
        <span class="tm__body" data-body>
          <span class="tm__clip" aria-hidden="true">
            <span class="tm__base"></span>
            <svg class="tm__chart" data-chart>
              <defs>
                <linearGradient id="tm-area" x1="0" y1="0" x2="0" y2="1">
                  <stop offset="0" stop-color="var(--accent)" stop-opacity="0.32"/>
                  <stop offset="1" stop-color="var(--accent)" stop-opacity="0"/>
                </linearGradient>
                <linearGradient id="tm-head" x1="0" y1="0" x2="0" y2="1">
                  <stop offset="0" stop-color="var(--accent)" stop-opacity="0.9"/>
                  <stop offset="1" stop-color="var(--accent)" stop-opacity="0"/>
                </linearGradient>
                <linearGradient id="tm-fade" data-fade gradientUnits="userSpaceOnUse" x1="0" y1="0" x2="20" y2="0">
                  <stop offset="0" stop-color="#fff" stop-opacity="0"/>
                  <stop offset="1" stop-color="#fff" stop-opacity="1"/>
                </linearGradient>
                <mask id="tm-mask" maskUnits="userSpaceOnUse" x="0" y="0" width="400" height="100" data-mask>
                  <rect data-mask-rect x="0" y="0" width="400" height="100" fill="url(#tm-fade)"/>
                </mask>
                <filter id="tm-blur" data-filter filterUnits="userSpaceOnUse" x="-20" y="-20" width="340" height="100">
                  <feGaussianBlur stdDeviation="2.6"/>
                </filter>
              </defs>
              <g class="tm__grid" data-grid></g>
              <path class="tm__ghost" data-ghost/>
              <path class="tm__area" data-area fill="url(#tm-area)" mask="url(#tm-mask)"/>
              <path class="tm__val" data-val/>
              <path class="tm__glow" data-glow filter="url(#tm-blur)"/>
              <path class="tm__line" data-line/>
              <rect class="tm__cursor" data-cursor width="1" fill="url(#tm-head)"/>
              <g class="tm__ticks" data-ticks></g>
              <text class="tm__value" data-value text-anchor="end">2.310</text>
            </svg>
            <span class="tm__shine" data-shine></span>
            <span class="tm__sweep"><span class="tm__sweep-band" data-sweep></span></span>
          </span>
          <span class="tm__rim" aria-hidden="true"></span>
          <span class="tm__row">
            <span class="tm__icon" aria-hidden="true">
              <svg viewBox="0 0 24 24">
                <path class="tm__mini-axis" d="M5 5v14h14"/>
                <path class="tm__mini" data-mini pathLength="1" d="M7.5 7.2c1.6 5.4 3.4 7.6 5.6 8.3 1.9.6 3.6.5 5.4.3"/>
                <path class="tm__check" data-check pathLength="1" d="M6.6 12.6l3.7 3.7 7.4-8"/>
              </svg>
            </span>
            <span class="tm__labels" aria-hidden="true">
              <span class="tm__label" data-label><span class="tm__main" data-word-rest>Train model</span></span>
              <span class="tm__label" data-label>
                <span class="tm__main tm__main--busy" data-word-busy>Training</span>
                <span class="tm__sub">Epoch <span class="tm__roll" data-epoch><span>1</span></span> of <span data-epochs>8</span></span>
              </span>
              <span class="tm__label" data-label>
                <span class="tm__main" data-word-done>Model ready</span>
                <span class="tm__sub">Accuracy <span data-acc>98.4</span>% · <span class="tm__ver" data-ver>v4</span></span>
              </span>
            </span>
            <span class="tm__chip" aria-hidden="true">
              <span class="tm__chip-face" data-chip>12k rows</span>
            </span>
          </span>
        </span>
      </button>
    </div>
    <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.

34 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 “Train model button” 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 near black page, with a cold light from above, a very fine grain and darker edges, a single graphite pill button 60 pixels tall sits in the middle: its one pixel edge catches the light at the top and stays in shadow at the bottom, and under the button the floor has just a hint of mint glow. On the left a round glass well with a small drawn chart (two axes and a falling mint curve), then the words Train model and on the right a glass chip with the size of the data, «12k rows». With the mouse over it, the words widen on the wdth axis, a soft light follows the pointer inside the pill, the icon’s little curve redraws itself and on the right appear a dotted grid, the eight epoch ticks on the bottom edge and the dotted ghost of the last run, passing behind the chip’s glass. Pressed, the button sinks by a pixel and narrows a little, then springs back. The chip blurs and disappears to make room for the chart, the words become Training with a band of light running through them and «Epoch 1 of 8» appears underneath; the icon’s curve runs like a loader. In the chart the loss curve draws itself from the left: it starts high and falls fast, then flattens with a slight tremble, with a mint area fading under it, a thin glow and a vertical line at its head; the validation curve, blue and dashed, follows it just above. At each epoch a tick on the bottom edge turns mint and the epoch number rolls up, while at the top right the loss falls from 2.310 to 0.087. At the end the curve flashes, the button swells by a hair and comes back, a diagonal reflection crosses the pill, the floor lights up, the icon folds away and a mint check draws itself in its place; the words become Model ready with «Accuracy 98.4% · v4» underneath, the accuracy counting up. After a couple of seconds the chart fades, the chip comes back on a small spring and the button is ready again. Until someone touches it, it goes round by itself; with mouse, finger and keyboard it really works.

How it works

A layered pill

The button’s body is a single box moved by GSAP (press and success); inside, a layer clipped with overflow: hidden holds the graphite with its gradient, the SVG chart, the light following the pointer (a radial-gradient with two CSS variables moved by gsap.quickTo) and the final reflection; on top sit the edge with three inner shadows and the row with the icon, the words and the chip.

The chart beside the words

On every resize a ResizeObserver measures where the widest of the labels ends (offsetLeft plus offsetWidth, hidden ones included) and the chart starts 20 pixels later: so the curve never runs under the text, on desktop or on the phone. Grid, epoch ticks, mask and ghost are rebuilt there.

Computed curves, not drawn ones

The three curves (training, validation, last run) are 181 samples computed once: an exponential decay normalised between 1 and 0 plus three sines for the noise, stronger at the start and almost nothing at the end. The path is rebuilt up to the progress p with a last interpolated point, and the area is the same path closed at the bottom, with a mask fading its left side.

One number moves everything

A timeline takes p from 0 to 1 in DURATION seconds: from the same value come the curve, the line at its head, the lit ticks (floor of p times EPOCHS), the epoch number, which rolls with yPercent only when it changes, and the loss written at the top, interpolated between START_LOSS and END_LOSS. The drawing is redone only when the state has changed.

The success

At the end the glow and the area rise in 0.14 seconds and settle, the body goes to 1.016 and back with elastic.out, a slanted band crosses the pill with xPercent, the icon’s little curve shrinks away and the check draws itself with pathLength 1 and strokeDashoffset; the accuracy counts up to its value.

Values to change

NameFileDefaultWhat it changes
LABEL_RESTscript.jsTrain modelThe words at rest.
LABEL_BUSYscript.jsTrainingThe words while the model trains.
LABEL_DONEscript.jsModel readyThe words at the end.
ROWSscript.js12k rowsThe chip at rest: how much data there is.
VERSIONscript.jsv4The new version of the model, written at the end.
EPOCHSscript.js8How many epochs the run has (one tick each on the bottom edge).
DURATIONscript.js4.2How many seconds the training takes.
START_LOSSscript.js2.31The loss at the start.
END_LOSSscript.js0.087The loss at the end.
ACCURACYscript.js98.4The accuracy shown at the end, in percent.
NOISEscript.js1How jittery the curve is: 0 smooth, 2 very noisy.
SPRINGscript.js1How springy the press is: 0.4 calm, 2 very bouncy.
HOLDscript.js1.8How many seconds Model ready stays before going back to rest.
AUTOscript.jstrueThe button goes round by itself until someone touches it.

Try them in the Playground

When to use it

For the main action of a platform that trains or fine-tunes artificial intelligence models, a data analytics app or a developer dashboard: training, importing, indexing, any few-second job with a number that gets better. The button itself becomes the chart, with no extra panel.

On phones

On the phone the button is at most 84% of the screen wide and the chart is recomputed to its size, always to the right of the words; there is no hover, so the light under the finger turns on at the touch and the rest, chart included, is the same.

With reduced motion

Nothing moves: the button does not sink, the whole curve fades in instead of drawing itself, the epoch and loss numbers change in place, the words swap with a fade and the check fades in.

Pitfalls

  • The curve drawn across the whole pill ran under «Training» and «Epoch» and made them unreadable: the chart now starts after the widest of the labels, measured on the hidden ones too, and the chip steps aside during training.
  • The area under the curve ended with a hard vertical cut at the start of the chart: an SVG mask with a userSpaceOnUse gradient, recomputed on resize, fades its first 22 pixels.
  • The epoch number in an inline-grid aligned to the bottom sat a couple of pixels above the rest of the line: aligned on the baseline, with the same line height, it stays in place while it rolls.
  • Rebuilding three paths every frame even at rest was wasted work: the drawing runs only when one of the six values of the state has changed.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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