Skip to content
animorio
IT
All components

Flashlight button

Buttons, HoverGSAP, CSS onlyMediumCompressed weight: Demo 5.0 KBGSAP 28 KBFreeDownload the zip

The Flashlight button of a control centre, on black. Tap it and the bulb catches twice, the circle turns warm white and a cone of light opens above it, reaching the top on a spring, while a glow spreads around. The four marks below pick the brightness: the cone widens or narrows and gets brighter or dimmer, from Low to Max. One more tap and the light goes back into the button.

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>
<!--
  "Flashlight 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>Flashlight 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 Flashlight button of a control centre: it throws a cone of light above itself,
         and the four marks below choose how strong and how wide the beam is -->
    <div class="fl" data-fl data-level="0">
      <span class="fl__sky" aria-hidden="true">
        <span class="fl__beam" data-beam></span>
        <span class="fl__core" data-core></span>
      </span>
      <button class="fl__btn" type="button" data-btn aria-pressed="false" aria-label="Flashlight">
        <span class="fl__halo" data-halo aria-hidden="true"></span>
        <svg viewBox="0 0 28 28" aria-hidden="true">
          <path class="fl__body" d="M9.200 9.800h9.600l-2 4.300v8.700a1.300 1.300 0 0 1-1.300 1.300h-3a1.300 1.300 0 0 1-1.300-1.300v-8.700Z"></path>
          <path class="fl__switch" d="M14 16.600v2.600"></path>
          <g class="fl__rays" data-rays><path d="M14 3.200v3.400"></path><path d="M8.300 4.700l1.500 2.800"></path><path d="M19.700 4.700l-1.500 2.800"></path></g>
        </svg>
      </button>
      <div class="fl__levels" role="group" aria-label="Brightness">
        <button type="button" data-seg aria-pressed="false" aria-label="Low"><i></i></button>
        <button type="button" data-seg aria-pressed="false" aria-label="Medium"><i></i></button>
        <button type="button" data-seg aria-pressed="false" aria-label="High"><i></i></button>
        <button type="button" data-seg aria-pressed="false" aria-label="Max"><i></i></button>
      </div>
      <p class="fl__label"><b>Flashlight</b><span class="fl__state"><span data-outstate>Off</span></span></p>
    </div>
    <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.

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 “Flashlight 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 glass circle with the outline of a flashlight; below, four unlit marks and the words “Flashlight”, “Off”. On opening button and marks rise into place. Tap the circle and it tightens and bounces, the light catches, drops and catches again in a moment like a bulb coming on, the circle turns warm white with the flashlight dark and three rays sprouting from its head, a glow spreads around and the cone of light opens above the button: it starts narrow and reaches the top going slightly past the point. The marks light up to the chosen level and the label rolls to “Medium”. Tap a mark and the cone widens or narrows on a spring and changes brightness, the tapped mark gives a kick, and the label says Low, Medium, High or Max. Tap the circle again and the cone comes back down into the button and everything goes off.

How it works

The cone, three numbers

The cone is an element with a gradient and a trapezoid clip-path. Three numbers describe it: how far up it reaches, how wide it is at the top and how bright. GSAP animates the numbers and a function rewrites clip-path and opacity on every frame.

Switching on

A small timeline makes the light catch twice in little more than a tenth of a second, then the cone’s length goes from zero to one with a slight overshoot. Inside sits a second cone, half as wide and brighter: the core of the beam.

The levels

Each mark is a button. Pick one and width and brightness go to that level’s values on an elastic spring; the big button remembers the last level used and comes back on with it.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#fff1ccThe colour of the light.
LEVELscript.js2The brightness the flashlight comes on with: 1 to 4.
OPENscript.js0.5How long the cone of light takes to open.

Try them in the Playground

When to use it

In the control centre of a phone or a watch, in the quick settings of a camera app, in the app of a lamp or a bike light; and wherever a switch also has an intensity: a home light, a backlight, the flash.

On phones

The same piece, at most 240 pixels wide: the circle is 76 pixels, the marks have a 30 by 24 touch area. The cone’s room is 150 pixels tall and gets shorter on low screens.

With reduced motion

The cone does not open or bounce: it fades in and out, already at its width, without the two flashes of switching on. The demo’s pointer does not start.

Pitfalls

  • The two flashes of switching on last little more than a tenth of a second and happen once: nothing flashes repeatedly, and with reduced motion they are not there.
  • The big button has aria-pressed; the marks are buttons with their own label (Low, Medium, High, Max), and the state is announced in an aria-live region.
  • The percentage clip-path follows the cone’s size by itself: nothing needs working out again on resize.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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