Skip to content
animorio
IT
Back to the library

Guitar tuner

SVG, HoverGSAP, CSS onlyMediumCompressed weight: Demo 7.2 KBGSAP 28 KBFreeDownload the zip

A guitar tuner: six strings to touch and a fan-shaped dial. The touched string rings, the needle swings to how far off it is and settles on the note as the string comes up to pitch; in tune, the letter gains weight and colour and the string gets its 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>
<!--
  "Guitar tuner" 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>Guitar tuner</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">
    <!-- a guitar tuner: touch a string, it rings, the needle swings to how far off it is and settles on the note
         as the string comes up to pitch; the letter gains weight when it is in tune -->
    <section class="tn" data-tn aria-label="Guitar tuner">
      <header class="tn__head">
        <span class="tn__brand">Tuner</span>
        <span class="tn__ref">Standard, A <b data-a4>440</b> Hz</span>
      </header>

      <div class="tn__gauge">
        <svg viewBox="0 0 300 150" aria-hidden="true">
          <path class="tn__zone" data-zone d=""></path>
          <g data-ticks></g>
          <text class="tn__end" x="42" y="112">flat</text>
          <text class="tn__end tn__end--r" x="258" y="112">sharp</text>
          <circle class="tn__ping" data-ping cx="150" cy="120" r="10"></circle>
          <g data-needle>
            <path class="tn__needle-shadow" d="M150 27 152.300 88h-4.600Z"></path>
            <path class="tn__needle" d="M150 27 152.300 88h-4.600Z"></path>
          </g>
        </svg>
        <p class="tn__note" aria-hidden="true"><span class="tn__letter"><span data-letter>E</span></span><sub data-octave>2</sub></p>
      </div>

      <p class="tn__read" aria-live="polite">
        <span class="tn__hz"><b data-hz>82.41</b> Hz</span>
        <span class="tn__say"><span data-say>Touch a string</span></span>
        <span class="tn__cents"><b data-cents>0</b> cents</span>
      </p>

      <div class="tn__strings" data-strings role="group" aria-label="Strings"></div>
    </section>

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

26 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 “Guitar tuner” 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 warm light background, a white card: at the top “Tuner” and the tuning, in the middle a fan-shaped dial of ticks with its needle and, in its hollow, the large letter of the note; below it the frequency, the status and the cents, and at the bottom the six strings, the three low ones bronze and thicker. Passing over a string (or tapping it), it rings like a wave that dies away, with a wider, fainter trail behind; the letter rolls to its note, the needle springs to how far off it is and trembles while the string sounds, the ticks near the needle grow longer. Then the string is brought to the note in two goes, the way a hand turns a peg: hertz and cents count, the status says “Tune up” or “Tune down”. At zero the needle and the letter turn orange, the letter gets heavier and wider, a ring widens around the letter, the string’s label fills and its tick is drawn. With all six, “All in tune”.

How it works

The string is a standing wave

Each string is a path of twenty points: the fundamental plus a little second harmonic, with an amplitude that falls exponentially over DECAY seconds. A wider, fainter copy a beat behind makes the trail.

One number in cents

The dial reads a single number: the needle turns through the transform attribute, the ticks within nine cents grow longer, the hertz come from A4 and the note’s MIDI number. The tremble comes from the string’s amplitude.

In tune

The string reaches zero in two goes (70% and then the rest); then the letter’s wght and wdth axes rise with back.out, a circle widens around the letter and the tick is drawn with stroke-dashoffset.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#ff5a36The colour of the note when it is in tune.
A4script.js440The reference A, in hertz: every frequency is worked out from it.
DETUNEscript.js28How many cents out the worst string is at the start.
TUNEscript.js1.1How many seconds a string takes to reach the note.
DECAYscript.js2.2How many seconds the string keeps ringing after the touch.
LOOPscript.jstrueLeft alone, a pointer tunes the six strings one after the other.

Try them in the Playground

When to use it

In a tuner app, a guitar course or an instrument shop, and as a widget in a music app. The same dial works for any reading that must come to zero: a level, a balance, a calibration.

On phones

The same piece: strings are tuned by tapping instead of hovering, the dial never exceeds 36% of the window’s height and the string rows tighten with the height.

With reduced motion

No vibration, swinging needle or rolling letter: touching a string, the dial is already at zero and the string is ticked.

Pitfalls

  • The tuning is fake: it does not listen to the microphone. In a real app the cents come from analysing the sound (getUserMedia and a pitch detector) and the needle follows that number.
  • The strings are real buttons with aria-pressed: hovering plays them, but tapping and the keyboard do the same.
  • The needle’s rotation lives in the transform attribute with its centre: GSAP’s transformOrigin on an SVG element is measured on its bounding box.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 17 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 animations