Skip to content
animorio
IT
All components

Translate button

Buttons, HoverGSAP, CSS onlyMediumCompressed weight: Demo 6.5 KBGSAP 28 KBFreeDownload the zip

The Translate button under a post in a product app, on white with a single blue: pressed, it says Translating with a spinning arc, then a soft light runs across the text and every Spanish word rises and blurs away while its English one drops into place, left to right, with a pixel of bounce. The button turns into Show original and the note below becomes «Translated from Spanish».

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>
<!--
  "Translate 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 Translate button that turns the words into another language</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: translate. A post written in Spanish sits in a card; pressing Translate makes a soft light run
         across the text while every word turns into its English one, left to right, and the button becomes
         Show original -->
    <article class="card" data-card aria-labelledby="autore">
      <header class="head">
        <span class="avatar" aria-hidden="true">
          <svg viewBox="0 0 40 40"><circle cx="20" cy="15.5" r="6.4"></circle><path d="M7.5 35c1.8-7 7-10.4 12.5-10.4S30.7 28 32.5 35"></path></svg>
        </span>
        <span class="who">
          <b id="autore">Lucía Ferrán</b>
          <span class="meta">Product lead at Loomwise <span class="sep" aria-hidden="true"></span> 2h</span>
        </span>
      </header>

      <div class="text" data-text>
        <p class="lang lang--from" data-from lang="es">Ayer probamos el nuevo flujo de pago con veinte tiendas. Todo fue más rápido de lo que esperábamos.</p>
        <p class="lang lang--to" data-to lang="en" aria-hidden="true">Yesterday we tested the new checkout flow with twenty shops. Everything was faster than we expected.</p>
        <span class="sheen" data-sheen aria-hidden="true"></span>
      </div>

      <footer class="foot">
        <span class="from" data-note aria-live="polite">
          <span class="from__a" data-note-a>Written in Spanish</span>
          <span class="from__b" data-note-b>Translated from Spanish</span>
        </span>

        <span class="tipwrap">
          <button class="tr" type="button" data-btn aria-pressed="false">
            <svg class="tr__icon" data-icon viewBox="0 0 24 24" aria-hidden="true">
              <path class="tr__a" d="M3.5 16.5 7.6 5.8h.8l4.1 10.7M5 12.7h6"></path>
              <path class="tr__b" d="M13.6 9.4h6.9M17 7.6v1.8M19.2 9.4c-.6 3.2-2.6 5.8-5.3 7.4M15.4 12.2c1 1.7 2.6 3.2 4.6 4.3"></path>
            </svg>
            <svg class="tr__arc" data-arc viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="7.5"></circle></svg>
            <span class="tr__labels">
              <span class="tr__label" data-l1>Translate</span>
              <span class="tr__label tr__label--2" data-l2>Translating</span>
              <span class="tr__label tr__label--3" data-l3>Show original</span>
            </span>
          </button>
          <span class="tip" data-tip role="tooltip">Translate to English</span>
        </span>
      </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.

25 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 “Translate 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 white sits the card of a post on Loomwise, an invented app: the drawn avatar, Lucía Ferrán, Product lead at Loomwise, two hours ago, and two sentences in Spanish about the new checkout flow tested with twenty shops. In the footer, on the left, the grey note Written in Spanish; on the right a white pill with a drawn icon, an A and a mark from another script, and the label Translate. Hovering tilts the icon slightly and the black tooltip Translate to English appears above. Pressed, the pill squashes and comes back on a spring, the label rises away and Translating arrives, the icon shrinks as it turns and a blue arc spins in its place. Then a blue and white light runs across the text from left to right and the Spanish words, one after another, rise six pixels, blur and vanish, while the English ones drop into place in blue, with a pixel of bounce, and turn black again. The text box follows the height of the new sentence. At the end the arc fades, the icon spins back, the pill turns pale blue with the label Show original widening on the wdth axis, and the note below becomes Translated from Spanish, in blue. Pressing Show original spins the icon a full turn and the words go back to Spanish, faster. A drawn pointer does it all by itself and starts again; it also works with mouse, touch and keyboard.

How it works

One word, one box

The two sentences share one cell of a grid, one on top of the other, and every word is an inline-block span: each can rise, blur and vanish on its own without moving the others, and the English sentence is already in place, invisible, before it arrives.

The light that reads

A band almost half as wide as the text, with a blue and white gradient in multiply, runs from left to right with xPercent. The leaving and arriving words start at times proportional to their place in the sentence, so they follow the light even when the two languages have a different number of words.

The pill that widens

The three button labels sit on top of each other in a box as wide as the one showing: on each change the box takes the new label’s width with back.out, and Show original arrives narrow on the wdth axis and widens while the pill swells.

The autopilot

A repeating timeline takes the drawn pointer to the button reading its real position every time, shows the tooltip, presses, lets you read the translation and goes back to the original. At the first real touch it stops, and it starts again after eight quiet seconds.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#2f6bffThe colour of the reading light, of the freshly translated words and of the switched-on button.
THINKscript.js0.45The seconds of Translating before the words start to change.
SWEEPscript.js1.15How many seconds the light takes to cross the text while every word changes language.
LIFTscript.js6How many pixels the leaving word rises and the arriving one drops.
BLURscript.js4How much a word blurs while it changes, in pixels.
PAUSEscript.js1.8The seconds the autopilot leaves to read the translation.

Try them in the Playground

When to use it

Under the posts and comments of a social app or a community, in shop or hotel reviews written in other languages, in the messages of a support app, anywhere AI translates a text in place.

On phones

The card takes the full width minus the margins, the text drops to 15 pixels and the pill stays 36 pixels tall, easy for a finger; under 360 pixels the note and the pill tighten a little to fit on one line. A tap does what a click does, and the tooltip only shows with a mouse or the keyboard.

With reduced motion

No running light, no hops and no blur: the two sentences swap with a fade, the button labels change in light, the arc appears and fades without turning and the drawn pointer stays hidden.

Pitfalls

  • With both sentences in the same grid cell, the box took the height of the longer one even while the shorter was being read: GSAP sets the height, that of the sentence being read, and measures it again on resize.
  • A blur filter left on the words after the animation kept each word on its own layer and the text looked slightly soft: at the end the filter is removed with clearProps.
  • Mona Sans’s tabular figures draw a slashed zero: they are not needed here and not used.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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