Skip to content
animorio
IT
All components

Sleep schedule

Dials, Hover, SVGGSAP, CSS onlyMediumCompressed weight: Demo 5.9 KBGSAP 28 KBFreeDownload the zip

An app’s sleep schedule, in a card on white: a 24-hour ring with midnight at the top and two handles to drag, the moon for bedtime and the sun for waking up. Between them a purple arc follows the handles, gliding, in the middle the hours of sleep count and below the two times roll. Under seven hours the arc, the icons and the pill at the top turn amber: “A little short”. The handles snap every quarter of an hour and move with the arrow keys too.

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>
<!--
  "Sleep schedule" 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>Sleep schedule</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 sleep schedule on a 24-hour ring: two handles to drag, bedtime and wake-up, the arc between them and
         the hours of sleep counting in the middle -->
    <section class="sl" data-sl aria-label="Sleep schedule">
      <header class="sl__head">
        <div class="sl__what"><strong>Sleep schedule</strong><span>Every night</span></div>
        <span class="sl__pill"><span class="sl__clip"><span data-outtone>Well rested</span></span></span>
      </header>

      <div class="sl__dial" data-dial>
        <svg class="sl__svg" data-svg viewBox="0 0 220 220">
          <circle class="sl__track" cx="110" cy="110" r="86"></circle>
          <g class="sl__ticks" data-ticks aria-hidden="true"></g>
          <path class="sl__arc" data-arc></path>
          <g class="sl__knob" data-knob="bed" role="slider" tabindex="0" aria-label="Bedtime" aria-valuemin="0" aria-valuemax="24"><circle r="15" class="sl__hit"></circle><circle r="10.500" class="sl__dot"></circle><path class="sl__ic" d="M2.400 -4.600A5.200 5.200 0 1 0 4.700 2.600A4.200 4.200 0 0 1 2.400 -4.600Z"></path></g>
          <g class="sl__knob" data-knob="wake" role="slider" tabindex="0" aria-label="Wake-up time" aria-valuemin="0" aria-valuemax="24"><circle r="15" class="sl__hit"></circle><circle r="10.500" class="sl__dot"></circle><circle class="sl__ic" r="2.600"></circle><path class="sl__ray" d="M0 -5.800v1.400M0 4.400v1.400M-5.800 0h1.400M4.400 0h1.400M-4.100 -4.100l1 1M3.100 3.100l1 1M-4.100 4.100l1 -1M3.100 -3.100l1 -1"></path></g>
        </svg>
        <div class="sl__mid" aria-hidden="true"><b data-outdur>8 h</b><span data-outsub>of sleep</span></div>
      </div>

      <dl class="sl__times">
        <div><dt>Bedtime</dt><dd><span class="sl__clip sl__clip--big"><span data-outbed>23:00</span></span></dd></div>
        <div><dt>Wake up</dt><dd><span class="sl__clip sl__clip--big"><span data-outwake>07:00</span></span></dd></div>
      </dl>
    </section>
    <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.

20 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 “Sleep schedule” 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 rounded card: at the top “Sleep schedule”, “Every night” and on the right the pale purple pill “Well rested”. In the middle a wide, very pale grey ring, with the hour ticks inside and four figures, 00 at the top, 06 on the right, 12 at the bottom, 18 on the left. On the ring a purple arc from 23 to 7, with round ends, and at each end a white handle with a shadow: a moon where you go to bed, a sun where you wake. In the middle a large “8 h” and “of sleep”. Below, two boxes: “Bedtime 23:00” and “Wake up 07:00”. At the start the arc opens from the moon to the sun. Dragging the moon along the ring the handle swells a little, the arc shortens following it smoothly, the count in the middle goes down a quarter of an hour at a time (“7 h” with “45 min of sleep” under it, then “30 min of sleep”) and the time below rolls. Under seven hours, arc and icons turn amber and the pill rolls to “A little short”. Dragging the sun the arc grows or shrinks from the other end. Past nine and a half hours the pill says “A long night”. Tab reaches the handles and the arrow keys move them by a quarter of an hour.

How it works

Two hours, one arc

Bedtime and wake-up time: from them come the two points on the ring, the arc between them (clockwise, past midnight too) and the hours of sleep.

From finger to hour

The angle between the ring’s centre and the pointer becomes an hour out of 24, rounded to the quarter: the finger does not have to stay right on the ring.

What you see chases

The chosen hour snaps, the drawn one catches up on a short spring and always the short way round, across midnight too.

The tone

One CSS variable colours arc, icons and pill: the class changes under the hours threshold, and the pill says it in words.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#5753d6The colour of the sleep arc when the hours are enough.
BEDscript.js23Bedtime at the start, in decimal hours (23.5 = 23:30).
WAKEscript.js7The wake-up time at the start.
SNAPscript.js15How many minutes the handles snap to.
ENOUGHscript.js7Under how many hours of sleep the arc changes colour.
LOOPscript.jstrueLeft alone, the demo’s pointer drags bedtime first and then wake-up.

Try them in the Playground

When to use it

In the settings of a sleep app, a watch or a phone, in a “do not disturb” mode, in a health app’s evening routine; the same two-handle ring carries a heating schedule, the quiet hours of notifications, a work shift or a fasting window.

On phones

The card is at most 316 pixels wide and about 345 tall. The ring is 204 pixels wide and narrows with the screen’s width and height; the handles have a 30-pixel target and drag with a finger without scrolling the page.

With reduced motion

The arc appears already open and, when dragging, jumps from one quarter of an hour to the next without gliding; the handles do not swell and times and pill change in one step. The demo’s pointer does not start.

Pitfalls

  • The handles are two `role="slider"` inside the svg, with the value read as a time and the arrow keys: without them, the ring only works with a pointer.
  • The drawn hour must take the short way: animating from 23.5 to 0.25 without correcting, the arc would go all the way round backwards.
  • The SVG arc has its “large arc” flag, which flips above twelve hours: if it is not updated, the arc draws the wrong part of the ring.
  • The tone is not just a colour: the pill writes “Well rested”, “A little short” or “A long night”, and when a handle is released the times are announced to screen readers.
  • The seven-hour threshold is a demo value, not medical advice: one knob changes it.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 2 December 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