Skip to content
animorio
IT
All components

Cast button

Buttons, Hover, SVGGSAP, CSS onlyEasyCompressed weight: Demo 5.1 KBGSAP 28 KBFreeDownload the zip

The button that casts to the TV in a streaming app. Pressed, the pill widens, the icon’s waves search one after the other, then the name of the TV it found appears; once connected the pill lights up, the screen in the icon fills in and a ring leaves the edge. One more press and it stops.

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>
<!--
  "Cast 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>Cast 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">
    <!-- a Cast button: the waves of the icon search one after the other, the TV is found by name,
         and the pill stays lit with the screen filled in while it is casting; one more press stops it -->
    <button class="cast" type="button" data-cast aria-pressed="false">
      <span class="cast__ring" data-ring aria-hidden="true"></span>
      <span class="cast__in" data-in>
        <svg class="cast__icon" viewBox="0 0 24 24" aria-hidden="true">
          <path class="cast__glass" data-glass d="M4.200 5.200h15.600v13.600h-6.500A10.300 10.300 0 0 0 4.200 9.300Z"></path>
          <path class="cast__screen" d="M3 8V6.500A2.500 2.500 0 0 1 5.500 4h13A2.500 2.500 0 0 1 21 6.500v11a2.500 2.500 0 0 1-2.500 2.500H14"></path>
          <path class="cast__wave" data-wave d="M3 11.500a8.500 8.500 0 0 1 8.500 8.500"></path>
          <path class="cast__wave" data-wave d="M3 15.500a4.500 4.500 0 0 1 4.500 4.500"></path>
          <circle class="cast__dot" data-wave cx="3.600" cy="19.400" r="1.300"></circle>
        </svg>
        <span class="cast__text">
          <span class="cast__roll cast__label" data-labelbox><span data-label>Cast</span></span>
          <span class="cast__roll cast__sub" data-subbox><span data-sub></span></span>
        </span>
      </span>
      <span class="cast__say" data-say aria-live="polite"></span>
    </button>
    <span class="cast__measure" data-measure aria-hidden="true"></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.

11 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 “Cast 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 black, a dark pill with the cast icon (a screen with two waves and a dot in the corner) and the word “Cast”. On press the pill widens on a spring to “Looking for devices”, and the icon’s waves light up from the dot outwards, over and over. After a moment the label rolls to “Living Room TV”, moves up a line and “Connecting” appears below; the pill tightens around the new label. Once connected the fill turns blue with a glow beneath, the screen in the icon fills in with a small bounce, a blue ring leaves the edge and fades, and under the name it says “Casting now”. One more press: the blue goes out, the screen empties, the label is “Cast” again and the pill returns to its size. Pressing while it searches cancels the search. A soft light follows the pointer along the pill.

How it works

Four states, one function

Idle, searching, found, casting: one function sets label, width, colours and icon for each state, and the timed steps are delayed calls that are cancelled if you press first.

As wide as its label

A hidden twin in the same type measures each state’s label; the pill gets there on an elastic spring, so when the TV’s name changes the size is already right.

The icon’s waves search

Dot and two arcs are three paths: a looping timeline lights them from nearest to farthest and dims them again, slightly offset. Once connected they stay lit and the screen fills in.

A toggle for those who cannot see

The button has aria-pressed and a hidden aria-live region says each step in words: searching, found, casting, stopped.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#4f7dffThe colour of the pill while it is casting.
SEARCHscript.js1.6How many seconds it searches before finding the TV.
CONNECTscript.js1How many seconds it takes to connect once found.
STRETCHscript.js1How elastic the pill is when its width changes: 0.3 = stiff, 2 = very elastic.
LOOPscript.jstrueLeft alone, the demo’s pointer casts and then stops.

Try them in the Playground

When to use it

In the player of a streaming, music or podcast app, on a video course page, in a photo app that sends pictures to the TV. The same sequence (search, find by name, stay lit) suits Bluetooth headphones, a printer, a speaker.

On phones

The same button, 58 pixels tall: you press it with a thumb. The pill never gets wider than the screen.

With reduced motion

The pill changes size, label and colour at once, with no springs or waves, and finds the TV right away. The demo does not move by itself.

Pitfalls

  • The TV and the timings are made up: a real button asks the Presentation API or the cast SDK for devices and moves to “found” when they answer.
  • The width must be measured after the font has arrived (document.fonts.ready), or the pill is born narrow on the fallback font.
  • The waves run on a looping timeline: it must be killed on a state change, not just paused, or it restarts over the new state.
  • The press bounce sits on an inner element: on the pill itself it would fight the width spring.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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