Scheduling
Slot Booking
A time slot fills with color and the booking is confirmed.
"use client";
import { useRef } from "react";
import gsap from "gsap";
import { useGSAP } from "@gsap/react";
gsap.registerPlugin(useGSAP);
export type SlotBookingProps = {
/** Day heading. */
day?: string;
/** Time slots, in order. */
slots?: string[];
/** Indexes of the slots that are already taken. */
busy?: number[];
/** Index of the slot the pointer picks. */
picked?: number;
/** Label shown in the confirmation bar. */
toast?: string;
/** Color of the picked slot and the confirmation label. */
accent?: string;
/** Replay forever with a pause between runs. */
loop?: boolean;
className?: string;
};
export default function SlotBooking({
day = "Saturday",
slots = ["9:00", "10:00", "11:00", "13:00", "14:00", "15:00", "16:00", "17:00", "18:00", "19:00"],
busy = [0, 2, 3, 6, 8, 9],
picked = 4,
toast = "Booked",
accent = "#1f5bff",
loop = true,
className = "",
}: SlotBookingProps) {
const root = useRef<HTMLDivElement>(null);
useGSAP(
() => {
const el = root.current as HTMLElement;
const q = gsap.utils.selector(root);
const pick = q("[data-slot='pick']")[0] as HTMLElement;
const fill = q("[data-fill]")[0];
const pointer = q("[data-pointer]")[0];
const bar = q("[data-toast]")[0];
// Centro do horário escolhido, em relação à caixa do componente. k desfaz a escala de quem
// mostra o componente reduzido: o retângulo medido vem escalado, o left/top do cursor não.
const aim = () => {
const a = el.getBoundingClientRect();
const b = pick.getBoundingClientRect();
const k = a.width ? el.offsetWidth / a.width : 1;
return { x: (b.left - a.left + b.width / 2) * k - 10, y: (b.top - a.top + b.height / 2) * k - 10 };
};
const tl = gsap.timeline({ repeat: loop ? -1 : 0, repeatDelay: 1.4 });
tl.set(fill, { scaleY: 0 })
.set(bar, { autoAlpha: 0, y: 10 })
.set(pointer, { left: 40, top: el.clientHeight * 0.72, autoAlpha: 1, scale: 1 })
.to(pointer, { left: () => aim().x, top: () => aim().y, duration: 0.8, ease: "power2.inOut" }, 0.3)
.to(pointer, { scale: 0.7, duration: 0.1, yoyo: true, repeat: 1 }, 1.15)
.to(fill, { scaleY: 1, duration: 0.4, ease: "power2.out" }, 1.2)
.to(pointer, { autoAlpha: 0, duration: 0.3 }, 1.5)
.to(bar, { autoAlpha: 1, y: 0, duration: 0.35, ease: "back.out(1.6)" }, 1.6)
.to({}, { duration: 1.8 });
if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) tl.progress(1).pause();
},
{ scope: root, dependencies: [loop, slots.join("|"), picked] },
);
return (
<div
ref={root}
className={`relative w-full max-w-[520px] overflow-hidden rounded-xl bg-[#efe7dd] p-[26px] pb-[92px] text-[#1a1916] ${className}`}
>
<p className="text-[11px] font-semibold tracking-[0.14em] text-neutral-500 uppercase">{day}</p>
<div className="mt-3 grid grid-cols-5 gap-1.5">
{slots.map((slot, i) => {
const isBusy = busy.includes(i);
const isPicked = i === picked;
return (
<div
key={slot}
data-slot={isPicked ? "pick" : undefined}
className={`relative flex h-[52px] items-end overflow-hidden rounded-sm border-[1.5px] border-[#1a1916] p-1.5 text-xs font-semibold ${
isBusy ? "bg-[#1a1916] text-[#ece6d8]" : "bg-transparent"
}`}
>
{isPicked ? (
<i data-fill aria-hidden="true" className="absolute inset-0 origin-bottom" style={{ backgroundColor: accent }} />
) : null}
<span className="relative">{slot}</span>
</div>
);
})}
</div>
<div
data-pointer
aria-hidden="true"
className="absolute h-5 w-5 rounded-full border-2 border-[#1a1916] bg-[#1a1916]/20"
/>
<div
data-toast
className="absolute inset-x-[26px] bottom-[18px] flex justify-between rounded-sm bg-[#1a1916] px-3 py-2.5 text-[13px] text-[#ece6d8]"
>
<span>
{day} · {slots[picked]}
</span>
<b className="font-semibold" style={{ color: accent }}>
{toast}
</b>
</div>
</div>
);
}
Paste this into Claude Code inside your project. It installs the skills your agent needs, asks for your texts and colors, and recreates this animation in your stack.
SkillsGSAP skillsHyperFrames · optional, for video
Claude Code
Recreate the "Slot Booking" animated component from Motionshelf (https://motionshelf-pi.vercel.app) in my current project, adapted to my brand. Answer me in the language I write to you in. Work in this order: 1. Tools: Check whether the official GSAP skills are installed (gsap-core, gsap-timeline, gsap-react). If they are not, ask me and then run `npx skills add https://github.com/greensock/gsap-skills` (choose Claude Code). If they do not show up in this session yet, read the SKILL.md files the installer created for gsap-timeline and gsap-react before writing code. 2. Project: Look at my project: framework (Next.js, Vite, plain HTML…), TypeScript or JavaScript, Tailwind or plain CSS. Build it as one component that fits this stack. In React use gsap and @gsap/react; in plain HTML use GSAP from npm or a CDN. 3. Ask me before coding: Ask me these in a single message, showing the example values as defaults: - the day, the list of times, which ones are taken and which one is picked - the confirmation label and the accent color - the language of the texts 4. The animation What it looks like: A day with a grid of time slots; some are taken (dark). A pointer picks a free slot, it fills with color, and a confirmation bar appears. Step by step: - At 0.3 s a round pointer moves to the picked slot (0.8 s, power2.inOut) and presses it. - At 1.2 s the slot fills with the accent color from the bottom (scaleY 0 → 1) and the pointer fades out. - At 1.6 s the confirmation bar pops up with the day, the time and a short label. Rules: - Use one GSAP timeline that loops forever with a short pause between runs (repeat: -1). If the step by step gives the pause, use that value; otherwise repeatDelay about 1.4 s. - Set every starting state with set() at the start of the timeline, never with from(): on the second loop from() starts from the wrong place. - Elements that appear later and would push the layout (new chat bubbles, new rows) stay display:none until their turn; elements that already have their place in the layout (a subtitle, a button) start hidden with autoAlpha 0, so nothing jumps. - If there is a cursor or pointer, it aims at the measured center of its target (getBoundingClientRect), never at fixed pixel coordinates; if the component is scaled, divide by the scale. - Blur only in the middle of a movement and always end at blur(0). - With prefers-reduced-motion, jump to the final frame and stop (tl.progress(1).pause()). - In React, use useGSAP from @gsap/react with a scope ref, so the timeline is cleaned up on unmount. - All example content stays generic (no real brands, logos or people). 5. Check: Run it and watch the first and the third loop (they must look the same). Check it at 390 px wide with no sideways scroll, with reduced motion turned on, and with a clean console. Tell me what you checked. 6. Video (optional): If I also want this as an MP4 (ads, stories, WhatsApp status), install the HyperFrames plugin with `claude plugin marketplace add heygen-com/hyperframes` and `claude plugin install hyperframes@hyperframes`, then use /hyperframes:hyperframes to render the same animation in 9:16, 1:1 or 16:9. Rendering needs FFmpeg installed, or render with --docker (downloads about 3.3 GB the first time). Ask me before installing. Shortcut: If I only want the ready-made component instead, it installs with `npx shadcn@latest add https://motionshelf-pi.vercel.app/r/slot-booking.json`.
Other agentsUsing Cursor, Codex, Gemini CLI or another agent? This version tells it to find its own way to load the same skills before it starts.
Other agents
Recreate the "Slot Booking" animated component from Motionshelf (https://motionshelf-pi.vercel.app) in my current project, adapted to my brand. Answer me in the language I write to you in. Work in this order: 1. Tools: These instructions were written for Claude Code, which uses "skills" (folders with a SKILL.md that teach it a technique). First find out how you load skills, rules or instructions, and get the same knowledge: (a) if your agent is supported by the skills installer, ask me and run `npx skills add https://github.com/greensock/gsap-skills --agent <your-agent>` (for example codex, opencode, antigravity); (b) otherwise copy the skill folders from https://github.com/greensock/gsap-skills into your skills or rules directory (in Cursor: Settings → Rules → Remote Rule (GitHub) → greensock/gsap-skills); (c) if you cannot load skills at all, open the SKILL.md files in https://github.com/greensock/gsap-skills and read them as instructions before coding. Tell me which path you used. 2. Project: Look at my project: framework (Next.js, Vite, plain HTML…), TypeScript or JavaScript, Tailwind or plain CSS. Build it as one component that fits this stack. In React use gsap and @gsap/react; in plain HTML use GSAP from npm or a CDN. 3. Ask me before coding: Ask me these in a single message, showing the example values as defaults: - the day, the list of times, which ones are taken and which one is picked - the confirmation label and the accent color - the language of the texts 4. The animation What it looks like: A day with a grid of time slots; some are taken (dark). A pointer picks a free slot, it fills with color, and a confirmation bar appears. Step by step: - At 0.3 s a round pointer moves to the picked slot (0.8 s, power2.inOut) and presses it. - At 1.2 s the slot fills with the accent color from the bottom (scaleY 0 → 1) and the pointer fades out. - At 1.6 s the confirmation bar pops up with the day, the time and a short label. Rules: - Use one GSAP timeline that loops forever with a short pause between runs (repeat: -1). If the step by step gives the pause, use that value; otherwise repeatDelay about 1.4 s. - Set every starting state with set() at the start of the timeline, never with from(): on the second loop from() starts from the wrong place. - Elements that appear later and would push the layout (new chat bubbles, new rows) stay display:none until their turn; elements that already have their place in the layout (a subtitle, a button) start hidden with autoAlpha 0, so nothing jumps. - If there is a cursor or pointer, it aims at the measured center of its target (getBoundingClientRect), never at fixed pixel coordinates; if the component is scaled, divide by the scale. - Blur only in the middle of a movement and always end at blur(0). - With prefers-reduced-motion, jump to the final frame and stop (tl.progress(1).pause()). - In React, use useGSAP from @gsap/react with a scope ref, so the timeline is cleaned up on unmount. - All example content stays generic (no real brands, logos or people). 5. Check: Run it and watch the first and the third loop (they must look the same). Check it at 390 px wide with no sideways scroll, with reduced motion turned on, and with a clean console. Tell me what you checked. 6. Video (optional): If I also want this as an MP4 (ads, stories, WhatsApp status), install the HyperFrames skills with `npx skills add heygen-com/hyperframes` (choose your agent) and render the same animation in 9:16, 1:1 or 16:9. Rendering needs FFmpeg installed, or render with --docker (downloads about 3.3 GB the first time). Ask me before installing. Shortcut: If I only want the ready-made component instead, it installs with `npx shadcn@latest add https://motionshelf-pi.vercel.app/r/slot-booking.json`.
Install
npx shadcn@latest add https://motionshelf-pi.vercel.app/r/slot-booking.jsonCopies the file into your project. Requires React 19, Tailwind CSS v4 and GSAP (installed as a dependency).
Props
| Name | Type | Default | Description |
|---|---|---|---|
| day | string | "Saturday" | Day heading. |
| slots | string[] | ten example times | Time slots, in order. |
| busy | number[] | [0, 2, 3, 6, 8, 9] | Indexes of the slots that are already taken. |
| picked | number | 4 | Index of the slot the pointer picks. |
| toast | string | "Booked" | Label shown in the confirmation bar. |
| accent | string | "#1f5bff" | Color of the picked slot and the confirmation label. |
| loop | boolean | true | Replay forever with a pause between runs. |
| className | string | "" | Extra classes for the outer element. |
Dependencies
- gsap
- @gsap/react