Skip to content
animorio
IT
All components

Regenerate answer button

Buttons, Hover, TextGSAP, CSS onlyMediumCompressed weight: Demo 7.4 KBGSAP 28 KBFreeDownload the zip

The Regenerate button under an invented AI assistant’s answer, on white: the circular arrow winds up and spins on a spring, a band of violet light runs across the answer and melts the words as it reaches them, the new version writes itself word by word while the card takes its height, and beside it the version counter opens and rolls from 1 / 2 to 2 / 2. The two small arrows go back to the previous version.

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>
<!--
  "Regenerate answer 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 Regenerate button that rewrites the answer with a sweep of light</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 gesture: press. An assistant's answer with its toolbar: Regenerate spins its arrow on a spring, a band of
         light passes over the answer and melts the words, the new version writes itself word by word, the card
         takes its new height, and the version pager appears and rolls from 1 / 2 to 2 / 2. The small arrows go back. -->
    <article class="card" data-card aria-label="Assistant answer">
      <span class="card__edge" data-edge aria-hidden="true"></span>
      <p class="ask" data-ask>Suggest an opening line for our spring launch email.</p>
      <header class="who">
        <span class="who__mark" aria-hidden="true">
          <svg viewBox="0 0 20 20"><path d="M10 2.6c.5 3.6 2.2 5.6 5.8 6.4-3.6.8-5.3 2.8-5.8 6.4-.5-3.6-2.2-5.6-5.8-6.4 3.6-.8 5.3-2.8 5.8-6.4Z"/></svg>
        </span>
        <span class="who__name">Orla</span>
        <span class="who__state" aria-live="polite"><span class="who__line" data-state>Answered in 1.2s</span></span>
      </header>
      <div class="answer" data-clip>
        <p class="answer__text" data-text></p>
        <span class="sweep" data-sweep aria-hidden="true"></span>
      </div>
      <footer class="bar">
        <button class="regen" type="button" data-regen aria-label="Regenerate answer">
          <span class="regen__bg" data-bg aria-hidden="true"></span>
          <span class="regen__icon" aria-hidden="true">
            <svg data-arrow viewBox="0 0 24 24"><path d="M19.4 12.6A7.5 7.5 0 1 1 17 6.6"/><path d="M17.6 2.8 17.2 6.9 13.1 6.5"/></svg>
          </span>
          <span class="regen__label">Regenerate</span>
        </button>
        <nav class="pager" data-pager aria-label="Answer versions">
          <button class="pager__btn" type="button" data-prev aria-label="Previous version">
            <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M9.8 3.8 5.6 8l4.2 4.2"/></svg>
          </button>
          <span class="pager__count" aria-live="polite"><span class="slot" data-now></span><span class="pager__of">/</span><span class="slot" data-all></span></span>
          <button class="pager__btn" type="button" data-next aria-label="Next version">
            <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M6.2 3.8 10.4 8l-4.2 4.2"/></svg>
          </button>
        </nav>
      </footer>
    </article>

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

19 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 “Regenerate answer 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

In the middle, on white, there is the card of a conversation with Orla, an invented AI assistant. At the top right the question, in a light grey bubble: suggest the opening line of the spring launch email. Below, Orla’s mark (a small white four-pointed star on a violet square), the name and a grey line, Answered in 1.2s; then the answer, a sentence for an invented notes app, Fieldnote 2. At the bottom, past a thin rule, the bar with the Regenerate button: a white pill with the circular arrow. Hovering it, the pill rises by a pixel, takes a soft violet tint and the arrow pulls back forty degrees, as if winding up. Pressed, the button squeezes and springs back, the arrow gives a small kick backwards and starts spinning, the line under the name leaves upwards and Writing… rises in its place, and the card’s border lights up with a violet light running along it. Meanwhile a soft band of light crosses the answer from left to right: each word, when the light reaches it, turns violet, blurs and disappears. Then the new answer writes itself word by word, each word arriving blurred and violet and settling black and sharp, and the card changes height with a small bounce if the answer is longer or shorter. When it is done the arrow stops on a spring at a full turn, the border goes dark, the card hops by a pixel, the line says Rewritten in 0.9s and beside the button the version counter opens, 1 / 2, with the number rolling straight on to 2. The small left arrow goes back to the previous version: the number rolls down, the words leave on one side and come in from the other. Up to three versions are kept. A drawn pointer does the round by itself: it regenerates, goes back to the first, on to the second, and then everything starts again.

How it works

The words, one by one

The answer is a paragraph with every word in an inline-block span and the spaces left as text, so lines wrap like prose and every word can be animated on its own with opacity, offset, blur and colour.

The light that melts

A band with a blurred violet gradient crosses the answer with xPercent in SWEEP seconds. Each word starts when the band reaches its centre: the word’s horizontal position, divided by the box width, multiplied by the duration, plus a little for every lower line.

Writing and height

The new text writes itself with a stagger of WORD_STAGGER seconds: each word arrives blurred, violet and four pixels lower. Before writing it the old height of the box is measured, then the new one, and GSAP goes from one to the other with back.out, then lets the height go free.

The arrow that spins and stops

On click a timeline gives a kick of 28 degrees backwards, a little over a turn that speeds up, then an endless turn. When the answer is written the turn stops and the arrow goes to the next full turn with elastic.out, so it always starts upright again.

The rolling counter

Each number sits in a one-line window with overflow hidden: the new number comes in from below while the old one leaves at the top (or the other way round going back), with back.out. The counter opens the first time by widening from zero to its natural width.

Values to change

NameFileDefaultWhat it changes
SWEEPscript.js1.05How many seconds the light takes to cross the answer and melt its words.
WORD_STAGGERscript.js0.032How many seconds between one word and the next while the new answer writes itself.
SPINscript.js0.7How long one turn of the arrow lasts while the answer is rewritten.
SQUEEZEscript.js0.95How much the button squeezes when pressed (1 = not at all).
MAX_VERSIONSscript.js3How many versions of the answer are kept, at most.
ACCENTscript.js#6d5efcThe colour of the light, of the border that lights up and of the freshly written words.
PROMPTscript.jsSuggest an opening line for our spring launch email.The question above the answer.

Try them in the Playground

When to use it

In apps with an AI assistant, under every answer: regenerating is something people do often, and here you see that the old answer doesn’t vanish at once but gets rewritten, and that it stays there, reachable with the version counter.

On phones

The card is at most 430 pixels wide and on the phone takes the width of the frame; the text wraps by itself and the spacing at the top and bottom tightens with the height, so card, answer and bar fit whole in the frame. You tap it like any button: no hover, the press still shows.

With reduced motion

No movement or spinning: the old answer fades out and the new one fades in, the height changes at once, the numbers change without rolling and the autopilot does not start.

Pitfalls

  • The spaces between words must be left as text between the spans: with the space inside an inline-block span lines wrap badly and the space at the line end sticks out.
  • The box height must be measured before changing the text and released at the end (height auto), otherwise on resize the card keeps its old height.
  • The arrow must go back to a full turn after the endless rotation: it rounds up to the next multiple of 360, otherwise it stops crooked.
  • The border that lights up is an element with a content-box mask: with an animated box-shadow the violet would show inside the card too.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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