Skip to content
animorio
IT
All components

Link preview tooltip

Tooltips, HoverGSAP, CSS onlyMediumCompressed weight: Demo 7.0 KBGSAP 28 KBFreeDownload the zip

An article paragraph with two links, on white, in the style of product interface pieces: hovering a link shows a small pill with the domain, and after half a second the pill grows on a spring into the preview card, with the page’s photo, the title, a line and the favicon, gently following the pointer. Moving to the other link the card slides over and changes content without closing; leaving, it shrinks back into the pill and disappears.

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 preview tooltip" 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 tooltip that becomes a link preview</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" data-stage>
    <!-- an article paragraph with two links: hovering one shows a small pill with the domain, which after a moment grows
         into a preview card that follows the pointer a little; moving to the other link slides the card over without closing it -->
    <article class="article" data-article aria-label="Slowbeam article">
      <p class="article__kicker">Slowbeam <span>/ Field notes</span></p>
      <h1 class="article__title">Why slow software feels fast</h1>
      <p class="article__text">
        Speed is mostly a feeling. Anything under a tenth of a second reads as instant, which is why
        <a class="ref" href="#" data-ref="0">the 100 ms rule</a> still shapes how good apps respond to a tap. But calm matters too:
        <a class="ref" href="#" data-ref="1">a recent field study</a> found people trust interfaces that settle gently over ones that snap.
      </p>
      <p class="article__meta">6 min read <span aria-hidden="true">·</span> Oct 2026</p>

      <div class="peek" data-peek role="tooltip" aria-hidden="true">
        <span class="peek__arrow" data-arrow></span>
        <div class="peek__pill" data-pill>
          <svg class="fav" data-fav-pill viewBox="0 0 16 16" aria-hidden="true"></svg>
          <span data-domain-pill>latency.report</span>
        </div>
        <div class="peek__card" data-card>
          <div class="peek__img" data-img>
            <img src="cronometro.webp" alt="A steel stopwatch dial at sixty" width="1024" height="768" decoding="async" data-photo="0">
            <img src="diario.webp" alt="A hand writing in a paper diary with a green pencil" width="960" height="640" decoding="async" data-photo="1">
          </div>
          <div class="peek__body">
            <p class="peek__title" data-title>Why 100 ms feels instant</p>
            <p class="peek__line" data-line>The numbers behind perceived speed, from taps to page loads.</p>
            <p class="peek__src" data-src>
              <svg class="fav" data-fav viewBox="0 0 16 16" aria-hidden="true"></svg>
              <span data-domain>latency.report</span>
              <svg class="peek__out" viewBox="0 0 16 16" aria-hidden="true"><path d="M6 4h6v6M12 4 5 11"></path></svg>
            </p>
          </div>
        </div>
      </div>
    </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.

29 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 “Link preview tooltip” 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 start of an article from Slowbeam, an invented magazine about software: the Field notes label, the headline «Why slow software feels fast» and a paragraph with two bold links on a very light violet tint, no underlines. Hovering a link lights up its tint and a small white pill appears below with the drawn favicon and the domain, latency.report or northloop.studio, with a little arrow pointing at the link. After half a second the pill grows on a short spring, goes a little past and settles, and becomes the preview card: on top the page’s photo, the steel dial of a stopwatch for latency.report or a hand writing in a planner with a green pencil for northloop.studio, slowly settling in its frame, below the page title, a grey line and the domain with the favicon and the exit arrow. The parts come in one after another from below, the shadow widens, and as the pointer moves along the link the card follows it by a few pixels. Moving to the other link the card does not close: it slides under the new link, the arrow follows, the old content rises and fades and the new one comes in with the other photo. Leaving the link the card shrinks back into the pill and disappears. If there is no room below it opens above the link. A drawn pointer reads the paragraph by itself; it also works with the mouse, with touch (a tap opens the card straight away, a second one closes it) and with the keyboard.

How it works

A single box

The pill and the card are the same element: GSAP changes its width, height, corners and place, and inside two layers take turns, the domain line fading and the card parts coming in staggered. So the opening is one spring and not two things replacing each other.

The right place

The card sits under the link’s box, shifted so the little arrow lands at a third of its width, and stays inside the article; if there is no room below it opens above and the arrow moves to the bottom edge. A link that wraps has two boxes: the one nearest to the pointer is used.

From one link to the other

If the card is already open it does not close: it moves on a light spring, the old content rises five pixels and fades, the new one comes in from below with a stagger. Leaving waits 180 milliseconds, so crossing the gap between two links makes nothing flicker. Both photos already sit in the card, one on top of the other: changing link only means showing the other one, with no wait for it to load.

The real pointer and the drawn one

Both go through the same function, which checks which link the point is on and moves the card with a quickTo that pulls it a few pixels towards the pointer. The autopilot is a timeline that moves the drawn pointer and calls that function on every frame; at the first real touch it stops for eight seconds.

Values to change

NameFileDefaultWhat it changes
DELAYscript.js0.5The seconds the domain pill stays before opening into the card.
FOLLOWscript.js14How many pixels the card follows the pointer along the link.
CARD_WIDTHscript.js300The width of the preview card, in pixels.
SPRINGscript.js1.3How far the card overshoots and comes back when it opens: 0 none, 2 a lot.
ACCENTscript.js#5b5bd6The colour of the lit link.
PAUSEscript.js1The seconds the autopilot stays on each link.

Try them in the Playground

When to use it

For the links of a blog, an online magazine, a documentation site or a newsletter read on the web: readers see where a link goes before leaving the page.

On phones

The paragraph takes the full width and the card narrows to the article’s width minus the margins, with the line under the title on a single line. With no hover, a tap on the link opens the card straight away and a second tap closes it.

With reduced motion

No spring and no following: the pill and the card appear and change in short fades, and the new content does not rise.

Pitfalls

  • A link that wraps has several boxes: getBoundingClientRect merges them into a rectangle as wide as the paragraph, so getClientRects and the box nearest to the pointer are used.
  • There is a ten-pixel gap between a link and the card: closing as soon as the pointer leaves the link would make the card vanish on the way to it. Leaving waits 180 milliseconds and is cancelled if the pointer reaches the card.
  • The preview photos are two img elements already loaded with the page, stacked, with object-fit: cover: loading them only when the link changes would bring the card in empty for a moment, and the frame is wide and short, so each has its own object-position to keep the part that matters in view (the stopwatch’s 60, the hand with the pencil).

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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