Skip to content
animorio
IT
All components

Dentist booking form

Forms, Hover, PhysicsGSAP, CSS onlyMediumCompressed weight: Demo 6.9 KBGSAP 28 KBFreeDownload the zip

The form for booking a visit at a dental practice. The treatment sets how long the visit block is, from 30 to 75 minutes; the block drags along the morning, over the times already taken, and when you let go it snaps on a spring to the nearest free time. The button says the chosen time and, pressed, becomes “Booked”.

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>
<!--
  "Dentist booking form" 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>Dentist booking form</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 booking form for a dental practice: the treatment sets how long the block is, the block is dragged
         along the morning and snaps on a spring to the nearest time that is really free -->
    <form class="dn" data-dn novalidate>
      <header class="dn__head">
        <h2 class="dn__title">Book a visit</h2>
        <p class="dn__sub">Tuesday 24 November</p>
      </header>

      <div class="dn__treat" data-treat role="radiogroup" aria-label="Treatment"></div>

      <div class="dn__day">
        <div class="dn__rail" data-rail>
          <span class="dn__land" data-land aria-hidden="true"></span>
          <span class="dn__block" data-block role="slider" tabindex="0" aria-label="Appointment time" aria-orientation="horizontal">
            <i></i><i></i><i></i>
          </span>
        </div>
        <div class="dn__hours" data-hours aria-hidden="true"></div>
      </div>

      <button class="dn__book" type="submit" data-book>
        <svg viewBox="0 0 20 20" aria-hidden="true"><path data-tick pathLength="1" d="M4.500 10.500l3.800 3.800L15.500 6.500"></path></svg>
        <span class="dn__roll"><span data-label>Book 9:00</span></span>
      </button>
      <span class="dn__say" data-say aria-live="polite"></span>
    </form>

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

13 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 “Dentist booking form” 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 card: “Book a visit” and the date. Four treatments in two rows, each with its length: Check-up 30 minutes, Cleaning 45, Filling 60, Whitening 75. Below, the morning from 9 to 13 as a white track, with two diagonally hatched stretches where the practice is already busy and a teal block that is the visit. Pick a longer treatment and the block widens on a spring and, if it no longer fits where it was, jumps to the nearest free time. Drag it and it follows the finger even over taken times, while a thin outline shows where it will land; let go and it snaps there with a bounce. The dark button at the bottom always says the time, “Book 10:00”, rolling when it changes; pressed, it turns teal, draws a tick and says “Booked for 10:00”, the rest of the form holding still. One more tap and you are choosing again.

How it works

The possible times

For each length the list of valid starts is worked out: on the fifteen-minute step, inside the morning, clear of the busy intervals. The block can only rest there.

Free while dragging, exact on release

While dragged the block follows the pointer to the minute; an outline shows the nearest valid start. On release a GSAP elastic takes the block to that start.

The treatment changes the width

Position and length live in one animated object: on a new treatment the width and, if needed, the start move in the same tween, so the block grows and shifts together.

Keyboard

The treatments are a radiogroup; the block is a slider: the arrows take it to the free time before or after, Home and End to the first and last, and aria-valuetext says the time.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#0f9b8eThe colour of the visit block and of the chosen treatment.
OPENSscript.js9When the practice opens: the morning shown lasts four hours.
STEPscript.js15How many minutes apart visits can start.
SPRINGscript.js1How elastic the block is when it snaps: 0.3 = stiff, 2 = very elastic.
LOOPscript.jstrueLeft alone, the demo’s pointer changes treatment, drags the block and books.

Try them in the Playground

When to use it

On the site of a dental practice, a doctor, a physiotherapist, a hairdresser or a garage: wherever services of different lengths have to fit into a day that already has commitments.

On phones

The same card, as wide as the screen: the track is 46 pixels tall, you can tap anywhere to bring the block there and dragging does not scroll the page.

With reduced motion

The block follows the finger and on release goes straight to the valid time, with no spring; width, labels and tick change at once. The demo does not move by itself.

Pitfalls

  • Treatments, lengths and busy times are made up: the real ones come from the practice’s diary, and the booking must be confirmed by the server before writing “Booked”.
  • A treatment may have no free time in the morning: here the longest has just one. With real data you need a “nothing free, try another day” state.
  • GSAP writes the block’s transform when it lifts it: the position lives in left, or the two cancel each other out.
  • The track has touch-action: none and captures the pointer, or on a phone dragging scrolls the page or is lost when leaving the edge.
  • Sizes are in minutes and become pixels on the track’s width: on resize the block and the outline must be redrawn.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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