Skip to content
animorio
IT
All components

Repeat button

Buttons, HoverGSAP, CSS onlyEasyCompressed weight: Demo 4.2 KBGSAP 28 KBFreeDownload the zip

The Repeat button of a music player, with its three states: off, repeat all, repeat one. On every tap the two arrows run half a turn around their loop and settle, the circle lights up blue, the label rolls and below three marks say where you are, the lit one longer. For a single track a small “1” pops out in the middle of the arrows.

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>
<!--
  "Repeat 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>Repeat button</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 repeat button of a music player, with its three states: off, repeat all, repeat one.
         On every tap the two arrows run half a turn around their loop, the label rolls and, for one track, a 1 pops out -->
    <button class="rp" type="button" data-rp data-state="off" aria-label="Repeat: off">
      <span class="rp__ico" aria-hidden="true">
        <svg data-loop viewBox="0 0 24 24"><path d="M17 2.500 20.500 6 17 9.500M3.500 11V9.500A3.500 3.500 0 0 1 7 6h13.500M7 21.500 3.500 18 7 14.500M20.500 13v1.500A3.500 3.500 0 0 1 17 18H3.500"></path></svg>
        <b data-one>1</b>
      </span>
      <span class="rp__text">
        <span class="rp__label"><span data-label>Repeat off</span></span>
        <span class="rp__marks"><i data-m></i><i data-m></i><i data-m></i></span>
      </span>
    </button>
    <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.

12 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 “Repeat 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, a light grey pill: on the left a white circle with the two repeat arrows in grey, then “Repeat off” with three marks below, the first black and longer. On opening the arrows run half a turn and stop. Tap the button and the pill tightens slightly and bounces, the arrows turn half a turn going past the point and back, the circle turns blue with white arrows, the pill takes a blue veil and edge, the label rolls to “Repeat all” and the long mark moves to the middle on a spring. On the second tap: “Repeat one”, the long mark on the right, and a small “1” pops out in the middle of the arrows. On the third everything goes off, back to “Repeat off”.

How it works

Three states in a row

An index from 0 to 2 that moves on at every tap and starts over. The state is written in an attribute of the button: CSS takes the colours from it, the script the label, the screen reader label and which mark is long.

The arrows

The icon looks the same every half turn: on each tap GSAP adds 180 degrees to the svg’s rotation, around its centre, on an elastic spring. It always ends upright.

The one and the marks

The “1” comes in from scale zero with a quarter turn, a moment after the arrows. The three marks change width, from 10 to 22 pixels, each on its own tween.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#2a6df4The colour of the button when repeat is on.
STARTscript.jsoffThe state on opening: off, all or one.
TURNscript.js0.9How long the arrows’ half turn lasts on every tap.

Try them in the Playground

When to use it

In the player of a music site, a radio, a podcast or audiobook app, next to Shuffle; and wherever an option has three values to cycle with a single tap: a list’s order, the light, dark or automatic theme.

On phones

The same button, 64 pixels tall and about 200 wide: it fits any screen and is tappable all over. In a narrow control bar just the circle can be kept, 48 pixels wide, with the label for screen readers.

With reduced motion

The arrows do not turn: on every tap the colours, the label and the long mark change and the “1” appears or goes at once. The demo’s pointer does not start.

Pitfalls

  • Three states do not fit aria-pressed, which has two: the state is in the button’s label (“Repeat: all tracks”) and is announced in an aria-live region.
  • The state is not told by colour alone: the label and the long mark change and, for a single track, the “1”.
  • The whole svg rotates, so the pivot is transformOrigin 50% 50%: svgOrigin only works for elements inside an svg.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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