Skip to content
animorio
IT
All components

Link shortener

Forms, HoverGSAP, CSS onlyMediumCompressed weight: Demo 5.6 KBGSAP 28 KBFreeDownload the zip

The field of a marketing tool that shortens an address: with “Shorten” the long link squeezes towards the left and the short one takes its place, with the alias after the slash ready to change. The character count drops from 86 to 14, a thin line shortens with it, and the button becomes “Copy” and then a tick.

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>
<!--
  "Link shortener" 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>Link shortener</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 link shortener of a marketing tool: the long address squeezes into the short link,
         the alias after the slash can be changed, and Copy confirms -->
    <form class="ls" data-ls data-state="long" novalidate>
      <div class="ls__top"><label class="ls__label" for="ls-url"><span data-outlabel>Long link</span></label><span class="ls__count"><b data-outcount>0</b> characters</span></div>
      <div class="ls__field" data-field>
        <input class="ls__input" id="ls-url" type="url" inputmode="url" autocomplete="off" spellcheck="false" data-input value="https://haldencandle.co/collections/winter?utm_source=newsletter&amp;utm_campaign=november">
        <span class="ls__squeeze" data-squeeze aria-hidden="true"></span>
        <span class="ls__short" data-short><span class="ls__domain" data-outdomain>hald.to/</span><input class="ls__alias" type="text" autocomplete="off" spellcheck="false" maxlength="18" aria-label="Alias" data-alias></span>
        <button class="ls__btn" type="submit" data-go><span class="ls__face" data-face="shorten">Shorten</span><span class="ls__face" data-face="copy">Copy</span><span class="ls__face" data-face="copied"><svg viewBox="0 0 16 16" aria-hidden="true"><path data-tick pathLength="1" d="m3.600 8.300 2.900 2.900 5.900-6.500"></path></svg></span></button>
      </div>
      <span class="ls__meter" aria-hidden="true"><i data-bar></i></span>
      <div class="ls__foot"><span class="ls__saved"><span data-outsaved>Paste a link and shorten it</span></span><button class="ls__new" type="button" data-new>New link</button></div>
    </form>
    <span class="live" aria-live="polite" data-live></span>

    <svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.200 19.200 11l-6.300 1.600-3.300 5.900Z"></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

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 “Link shortener” 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: the label “Long link” with the count “86 characters”, a pale grey field holding the long address (cut by an ellipsis) and inside it, on the right, the dark “Shorten” button; below, a thin black line as long as the field and the sentence “Paste a link and shorten it”. On tap the address squeezes towards the left as if compressed and fades; in its place “hald.to/winter” arrives on a spring, with the domain in grey and the alias in green, which can be rewritten. The field takes a green border, the label rolls into “Short link”, the count runs down to 14, the line shrinks to a sixth and turns green, and below “72 characters shorter, 84% less” appears with “New link” on the right. The button has become “Copy”: on tap it shows the tick drawing itself, then goes back to “Copy”. Changing the alias after the slash updates count and line. “New link” takes everything back to the long address.

How it works

The squeezing address

A text field cannot be squashed letter by letter: a copy of the address sits on top of it, and GSAP narrows that one towards the left while it fades. The short link comes in just before it ends.

One number for the length

A single number goes from the long link’s characters to the short one’s: it writes the count and, divided by the starting length, gives the size of the line under the field.

One button, three faces

Shorten, Copy and the tick sit on top of each other in the same button: at every step one lifts away and the next comes up from below. After copying, a GSAP delay brings Copy back.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#0f9d74The colour of the short link, the border and the line after shortening.
DOMAINscript.jshald.toThe short domain.
ALIASscript.jswinterThe alias suggested after the slash.
SQUEEZEscript.js0.7How many seconds the long address takes to squeeze.
SPRINGscript.js1How much the button and the short link bounce.

Try them in the Playground

When to use it

In a marketing, newsletter or social tool, where campaign links with UTM parameters are prepared; on the share page of a file or document; in any form that turns a long value into a short one to copy.

On phones

The block is at most 336 pixels wide and about 130 tall, and narrows with the screen: the long address is cut with an ellipsis, the button stays 92 pixels wide and 44 tall. You type and tap with a thumb; nothing depends on hover.

With reduced motion

The long address gives way to the short one at once, without squeezing; count and line take their new value immediately, the words change without rolling and the tick is already drawn. The demo’s pointer does not start.

Pitfalls

  • It is a real form: Enter in the field shortens, and once shortened it copies. The alias after the slash only takes lowercase letters, digits and hyphens.
  • The squeezing copy is hidden from screen readers; the short link and how many characters are saved are read out in an aria-live region.
  • The button has three faces but one name at a time (aria-label): the tick alone would say nothing.
  • Here the short link is fake and made in the script: in a real product the server creates it, and also says whether the alias is taken.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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