Skip to content
animorio
IT
All components

Get directions button

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

The «Get directions» button on the site of an invented car dealership, Morrow & Vale: a graphite pill on white with the turn sign in a dark disc and the drive minutes on the right. Pressed, the label lifts away and a small street plan lights up inside the pill: the route draws itself in blue from the turn sign to the showroom, the navigation arrow at its tip turning at every corner, while the odometer of the minutes rolls from 18 to 14 and the miles count up. At the end the showroom pin drops and squashes, and a glint runs along the route and across the pill.

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>
<!--
  "Get directions 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 Get directions button with the route that draws itself and the drive time that rolls</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 Get directions button of a car dealership's site, a graphite pill on white. On hover a soft light follows
         the pointer and the turn sign leans its arrow. Pressed, the words lift away and a little street plan lights up
         inside the pill: the route draws itself from the turn sign to the showroom, a small navigation arrow riding its
         tip, while the drive time rolls on the odometer from the usual estimate to the live one and the miles count up.
         At the end the showroom pin drops and squashes, a glint runs along the route and the chip says the time.
         Pressed again, the route rolls back up and the words return -->
    <div class="gd" data-wrap>
      <span class="gd__spill" data-spill aria-hidden="true"></span>
      <button class="gd__btn" type="button" data-btn aria-label="Get directions to the Morrow and Vale showroom">
        <span class="gd__body" data-body>
          <span class="gd__fill" aria-hidden="true"></span>
          <span class="gd__glow" aria-hidden="true"><span class="gd__glow-light" data-glow></span></span>
          <span class="gd__shine" data-shine aria-hidden="true"></span>
          <span class="gd__sweep" aria-hidden="true"><span class="gd__sweep-band" data-sweep></span></span>
          <span class="gd__edge" aria-hidden="true"></span>
          <span class="gd__row">
            <span class="gd__disc" data-disc aria-hidden="true">
              <span class="gd__plate" data-plate></span>
              <svg class="gd__sign" data-sign viewBox="0 0 24 24">
                <path class="gd__sign-shape" d="M12 2.6 21.4 12 12 21.4 2.6 12Z"/>
                <g data-turn>
                  <path class="gd__sign-arrow" d="M9.4 15.6v-3.1c0-.9.7-1.6 1.6-1.6h4.2"/>
                  <path class="gd__sign-arrow" d="M13.4 8.9l2 2-2 2"/>
                </g>
              </svg>
              <svg class="gd__nav" data-nav viewBox="0 0 24 24">
                <path d="M12 3.4 18.8 19.4 12 15.8 5.2 19.4Z"/>
              </svg>
            </span>
            <span class="gd__mid" data-mid>
              <span class="gd__text" data-text aria-hidden="true">
                <span class="gd__title" data-title>Get directions</span>
                <span class="gd__sub" data-sub>Morrow &amp; Vale showroom</span>
              </span>
              <svg class="gd__map" data-map aria-hidden="true">
                <g class="gd__streets" data-streets></g>
                <path class="gd__route-under" data-under/>
                <path class="gd__route-glow" data-route-glow/>
                <path class="gd__route" data-route/>
                <path class="gd__route-shine" data-route-shine/>
                <path class="gd__start" data-start/>
                <g class="gd__car" data-car><path d="M0 -4.6 3.6 3.8 0 2 -3.6 3.8Z"/></g>
                <g data-pin-pos>
                  <ellipse class="gd__pin-shadow" data-pin-shadow cx="0" cy="0" rx="4" ry="1.3"/>
                  <g class="gd__pin" data-pin>
                    <path class="gd__pin-body" d="M0 0C-1.2-3.4-6.2-7.2-6.2-11.4a6.2 6.2 0 0 1 12.4 0C6.2-7.2 1.2-3.4 0 0Z"/>
                    <path class="gd__pin-mark" d="M-3.1-10.9 0-13.6 3.1-10.9V-8.6H-3.1Z"/>
                  </g>
                </g>
              </svg>
            </span>
            <span class="gd__chip" aria-hidden="true">
              <span class="gd__eta">
                <span class="gd__col" data-col></span><span class="gd__col" data-col></span>
                <span class="gd__unit">min</span>
              </span>
              <span class="gd__chip-sub">
                <span class="gd__chip-face" data-face>Drive</span>
                <span class="gd__chip-face" data-face><span data-dist>0.0</span> mi</span>
              </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.

24 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 “Get directions 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 white page sits one graphite pill, 60 pixels tall, with a thin edge that catches the light at the top, a light grain and a soft layered shadow on the page. On the left, in a sunken dark disc, the diamond sign of a right turn; in the middle «Get directions» and under it «Morrow & Vale showroom»; on the right the usual drive minutes, «18 min», on a small odometer, and under them «Drive». On hover a soft light follows the pointer, the sign leans a few degrees and its arrow moves forward a pixel and a half on an elastic. Pressed, the pill gives and returns; the label lifts and fades, the sign turns and shrinks and the blue navigation arrow arrives in its place on a spring, while the disc lights up blue. Inside the pill a plan of thin streets lights up, with blocks and a small park: from the start mark the blue route draws itself along the middle street, turns into the side streets with rounded corners and reaches the showroom, a white arrow at its tip following the road and turning at every corner. Meanwhile the odometer rolls: the two wheels of digits spin, the units one turn more, and stop on «14» with a small settle; underneath, «Drive» gives way to the miles counting up to 6.2. A blue light grows from the disc through the pill and a blue reflection settles on the page under it. On arrival the arrow slips into the showroom pin, which drops, squashes and straightens with its shadow; a white glint runs along the route and another crosses the pill. Pressing again lifts the pin, rewinds the route to the start, dims the streets, rolls the minutes back to 18 and brings the label back.

How it works

The plan in real pixels

The street plan is an svg whose viewBox is as big as the middle of the pill, measured with clientWidth: three horizontal streets at 30, 50 and 70 percent of the height, cross streets every eighth of the width, a diagonal avenue, blocks as faint rectangles skipping some cells and a green cell for the park. A ResizeObserver rebuilds it when the pill changes width, even halfway through the drawing, because the route's progress is a number from 0 to 1 and not a length.

The route with rounded corners

The route's points zig zag between the middle street and the two side ones (CORNERS corners); at each corner the line stops 5 pixels short and goes on with a quadratic curve that has the corner as its control point. The same d goes to four paths: the dark shadow underneath, the blurred glow, the blue line and the glint; the first three draw with a strokeDasharray equal to the length and a falling strokeDashoffset.

The arrow that follows the road

Every frame getPointAtLength gives the point at the tip and the one a pixel and a half before it: their direction through atan2 is the rotation of the white arrow, which so turns by itself at every junction. The same update writes the miles, DISTANCE times the route's progress.

The odometer

Each digit is a strip of sixty numbers (0 to 9 six times) inside a window 1.1 em tall faded at the top and bottom with a mask. To reach 14 the wheel always moves forward to the right digit plus TURNS turns, the units one turn more than the tens and 0.12 seconds slower; a light back.out passes the mark by a breath and returns, then the strip jumps back to its 0 to 9 position without showing.

The arrival

The arrow shrinks into the end point while the pin drops on power3.in already a little stretched; on touching down it squashes (scaleX 1.22, scaleY 0.78) from its bottom origin and straightens on an elastic.out, its shadow widening with it. Then a 16 pixel white stroke runs along the route with strokeDashoffset and a band of light in screen blend crosses the graphite.

Values to change

NameFileDefaultWhat it changes
DEALERscript.js'Morrow & Vale'The dealership's name, in the small line under the label.
USUALscript.js18The usual drive minutes, shown at rest (10 to 99).
ETAscript.js14The minutes with live traffic, where the odometer stops (10 to 99).
DISTANCEscript.js6.2The miles of the route, counted while it draws.
DRAWscript.js1.9The seconds the route takes to draw itself.
TURNSscript.js1The extra turns of the odometer wheels while the route draws.
CORNERSscript.js3How many streets the route turns into before the showroom.
SPRINGscript.js1How springy the moves are: 0.4 calm, 2 very bouncy.
HOLDscript.js2.4The seconds the found route stays before going back.
AUTOscript.jstrueWhether it goes round by itself until someone touches it.

Try them in the Playground

When to use it

On the contact page or in the footer of the landing page of a car dealership, a showroom, a garage or a car rental: the button that leads to the directions. It also suits a restaurant, a hotel, a shop or an event with an address, anywhere a «how to get here» with the drive time is needed.

On phones

The same animation with adapted sizes: the pill is 88% of the screen wide up to 328 pixels and stays 60 tall, easy for a finger; the street plan rebuilds itself on the real width, so the route always has the same corners. Under 360 pixels the label tightens a little with the wdth axis. A tap does what a click does and the light follows the finger while it rests on the pill.

With reduced motion

Nothing moves: the label and the sign fade away, the navigation arrow fades in, the plan appears with the route already drawn and the pin already in place, the minute digits change with a fade instead of rolling, no running arrow and no glints. The way back is the same fade in reverse.

Pitfalls

  • With the route measured in percentages of the viewBox and preserveAspectRatio=none the curves squashed and the arrow warped: the viewBox is as big as the middle of the pill in pixels and is rebuilt with a ResizeObserver.
  • The arrow turned from the difference between two points too close together shook at the corners: the reference point sits a pixel and a half behind the tip, and at the start the length begins at 0.01 so the two points are never the same.
  • Odometer wheels going backwards looked like a countdown: they always spin forward to the right digit, and once the run is over the strip jumps back between 0 and 9 so the next run has room.
  • With Mona Sans tabular-nums gives a slashed zero: each digit sits in a centred window 0.6 em wide, without tnum.
  • The fade at the sides of the plan (mask-image) goes on the svg and not on the middle of the pill, otherwise it also faded the label as it came back.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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