Kick-off
Calls to action, submit. Curls into the top corner, the net bulges.
- Sport
- Football
- Move
- Curls into the top corner, the net bulges.
- For
- Calls to action, submit
flight 760ms on a curve · net bulge 700ms · reduced: label swap
01 Install
npx shadcn@latest add https://moveui-red.vercel.app/r/kick-off.jsonIt brings the tokens with it, and Rolling ball, which it uses. The first time, import the tokens once in your root layout:
import "@/components/moveui/tokens.css";Not using shadcn? Copy the files below into components/moveui/, and tokens.css next to them.
02 Use it
import { KickOff } from "@/components/moveui/kick-off/kick-off";
<KickOff label="Sign up" goalLabel="You're in!" onScore={() => submit()} />03 Or ask your agent
Paste this into Claude Code, Cursor or any coding agent. It installs the piece and wires it in.
Add the Move UI "Kick-off" piece to this project. It's for: Calls to action, submit.
1. Install it: npx shadcn@latest add https://moveui-red.vercel.app/r/kick-off.json
2. If the project doesn't import the Move UI tokens yet, add this once to the root layout: import "@/components/moveui/tokens.css";
3. Use it like this, adapted to where it belongs in my code:
import { KickOff } from "@/components/moveui/kick-off/kick-off";
<KickOff label="Sign up" goalLabel="You're in!" onScore={() => submit()} />
Keep its reduced-motion behaviour and keyboard support. Don't hardcode durations, easing or colours: they come from the --ml-* tokens.
Docs: https://moveui-red.vercel.app/pieces/kick-offWant your agent to know the whole library and its motion rules? Add the Move UI skill to your project:
npx shadcn@latest add https://moveui-red.vercel.app/r/skill.json04 Code
"use client";
import { useEffect, useRef, useState } from "react";
import { BallSeams } from "../rolling-ball/rolling-ball";
import "../rolling-ball/rolling-ball.css";
import "./kick-off.css";
/**
* Kick-off: a call to action with a goal. Click it and the ball leaves the button, curls into the
* top corner, the net pockets it and springs back, the ball drops in and the label pops to "Goal!". Then the ball is set again.
* The flight runs on --ml-dur-flight. onScore fires when the ball hits the net, so the real action
* (submit, navigate) can follow the moment. Reduced motion: no flight, the label simply swaps.
*/
type Props = { label?: string; goalLabel?: string; onScore?: () => void; resetAfter?: number };
/*
The net, in the goal's own units (viewBox 120 x 72). Every cord runs post to post and bar to ground,
so it stays tied to the frame. On impact the net forms a pocket: the cords around the ball travel
with it, the rest of the net follows a little, then it all springs back.
*/
const ROWS = [16, 28, 40, 52, 64];
const COLS = [20, 32, 44, 56, 68, 80, 92, 104];
const X0 = 5.5, X1 = 114.5, Y0 = 5.5, Y1 = 71;
const SAMPLES = 24;
/** Where the ball strikes: high, near the right post. */
const HIT = { x: 90, y: 20 };
type Pt = [number, number];
const CORDS: Pt[][] = [
...ROWS.map((y) => Array.from({ length: SAMPLES + 1 }, (_, i): Pt => [X0 + ((X1 - X0) * i) / SAMPLES, y])),
...COLS.map((x) => Array.from({ length: SAMPLES + 1 }, (_, i): Pt => [x, Y0 + ((Y1 - Y0) * i) / SAMPLES])),
];
const bell = (d2: number, r: number) => Math.exp(-d2 / (2 * r * r));
/** The cords as path data with the pocket pushed by (px, py) units at the hit point. */
const netPaths = (px: number, py: number) =>
CORDS.map((cord) =>
cord.map(([x, y], i) => {
const d2 = (x - HIT.x) ** 2 + (y - HIT.y) ** 2;
const tied = Math.sin((Math.PI * i) / SAMPLES); // the ends stay on the frame
const k = (bell(d2, 12) + 0.2 * bell(d2, 42)) * tied;
return `${i ? "L" : "M"}${(x + px * k).toFixed(2)} ${(y + py * k).toFixed(2)}`;
}).join(""),
);
const REST = netPaths(0, 0);
/** A duration token in ms. Browsers may serialise it as "760ms" or "0.76s", so read the unit. */
const ms = (el: Element, name: string, fallback: number) => {
const raw = getComputedStyle(el).getPropertyValue(name).trim();
const v = parseFloat(raw) * (/[^m]s$/.test(raw) ? 1000 : 1);
return Number.isFinite(v) ? v : fallback;
};
export function KickOff({ label = "Kick off", goalLabel = "Goal!", onScore, resetAfter = 1800 }: Props) {
const box = useRef<HTMLDivElement>(null);
const ball = useRef<HTMLSpanElement>(null);
const goal = useRef<SVGSVGElement>(null);
const net = useRef<SVGGElement>(null);
const raf = useRef(0);
const [state, setState] = useState<"set" | "flying" | "scored">("set");
const anims = useRef<Animation[]>([]);
const timers = useRef<ReturnType<typeof setTimeout>[]>([]);
useEffect(() => () => {
timers.current.forEach(clearTimeout);
anims.current.forEach((a) => a.cancel());
cancelAnimationFrame(raf.current);
}, []);
const later = (fn: () => void, t: number) => timers.current.push(setTimeout(fn, t));
const kick = () => {
const b = ball.current, g = goal.current, n = net.current, root = box.current;
if (state !== "set" || !b || !g || !n || !root) return;
const reduce = matchMedia("(prefers-reduced-motion: reduce)").matches;
const flight = ms(root, "--ml-dur-flight", 760);
const reset = () => later(() => {
anims.current.forEach((a) => a.cancel());
anims.current = [];
cancelAnimationFrame(raf.current);
n.querySelectorAll("path").forEach((el, i) => el.setAttribute("d", REST[i]));
b.style.transform = "";
setState("set");
}, resetAfter);
if (reduce) {
setState("scored");
onScore?.();
reset();
return;
}
setState("flying");
const br = b.getBoundingClientRect(), gr = g.getBoundingClientRect();
const sx = gr.width / 120, sy = gr.height / 72;
const cx = br.left + br.width / 2, cy = br.top + br.height / 2;
// Target: the top corner, relative to where the ball sits on the button.
const tx = gr.left + HIT.x * sx - cx;
const ty = gr.top + HIT.y * sy - cy;
// The curl, seen from behind the striker: low and wide first, then it rises and bends into the
// top corner through the mouth of the goal (a quadratic curve).
const c1x = tx * 0.86, c1y = ty * 0.18;
const DEEP = 0.5; // scale at the net: the ball has travelled away from us
const flightFrames = Array.from({ length: 31 }, (_, i) => {
const t = i / 30, e = 1 - Math.pow(1 - t, 1.25), m = 1 - e; // a little air drag, no crawl
const x = 2 * m * e * c1x + e * e * tx;
const y = 2 * m * e * c1y + e * e * ty;
return { transform: `translate(${x}px, ${y}px) rotate(${e * 720}deg) scale(${1 - e * (1 - DEEP)})` };
});
const shot = b.animate(flightFrames, { duration: flight, easing: "linear", fill: "forwards" });
anims.current.push(shot);
// Impact. One clock drives the net and the ball together, so the ball sits in the pocket the net
// makes, rides the recoil, then falls to the ground and bounces. A WAAPI clock follows the document
// timeline (and DevTools' playback rate) like every other animation here.
shot.finished.then(() => {
const cords = Array.from(n.querySelectorAll("path"));
// Incoming direction (end of the curve), in goal units.
// The pocket stretches along the ball's path and back into the goal (up and right, away from us).
const vx = (tx - c1x) / sx, vy = (ty - c1y) / sy, vl = Math.hypot(vx, vy) || 1;
const ax = vx / vl + 0.9, ay = vy / vl - 0.1, al = Math.hypot(ax, ay) || 1;
const ux = ax / al, uy = ay / al;
const POCKET = 11; // how far the net stretches, in goal units
const HOLD = 230, FALL = 330, BOUNCE = 190, TOTAL = 1100;
const groundY = 69 - (br.height * DEEP * 0.82) / 2 / sy; // ball resting on the goal line
const clock = n.animate([{ opacity: 0.6 }, { opacity: 0.6 }], { duration: TOTAL, fill: "forwards" });
anims.current.push(clock);
shot.cancel();
const place = (ux_: number, uy_: number, rot: number, sc: number) => {
b.style.transform = `translate(${tx + (ux_ - HIT.x) * sx}px, ${ty + (uy_ - HIT.y) * sy}px) rotate(${rot}deg) scale(${sc})`;
};
let releaseX = HIT.x, releaseY = HIT.y;
const step = () => {
const ms_ = Math.min(TOTAL, Number(clock.currentTime ?? TOTAL));
// The pocket: out fast, back past rest, settle (a damped spring).
const q = ms_ / 700;
const d = q < 1 ? POCKET * Math.exp(-3.4 * q) * Math.sin(Math.min(Math.PI * 2.4 * q, Math.PI * 2.4)) : 0;
netPaths(ux * d, uy * d).forEach((p, i) => cords[i]?.setAttribute("d", p));
if (ms_ < HOLD) {
// In the net: the ball rides the pocket and sinks a little deeper.
releaseX = HIT.x + ux * d; releaseY = HIT.y + uy * d;
place(releaseX, releaseY, 720 + ms_ * 0.25, DEEP * (1 - 0.18 * Math.sin((Math.PI * ms_) / HOLD)));
} else {
// Let go: gravity to the goal line, one small bounce, a short roll back out.
const t = ms_ - HOLD;
let y: number;
if (t < FALL) y = releaseY + (groundY - releaseY) * (t / FALL) ** 2;
else if (t < FALL + BOUNCE) { const k = (t - FALL) / BOUNCE; y = groundY - 7 * 4 * k * (1 - k); }
else y = groundY;
const roll = 1 - Math.exp(-t / 260);
place(releaseX - 9 * roll, y, 780 - 140 * roll, DEEP * 0.82);
}
if (ms_ < TOTAL && clock.playState !== "idle") raf.current = requestAnimationFrame(step);
};
raf.current = requestAnimationFrame(step);
setState("scored");
onScore?.();
reset();
}, () => { /* cancelled: the card unmounted or was reset */ });
};
return (
<div ref={box} className="ml-kickoff" data-state={state}>
<svg ref={goal} className="ml-kickoff__goal" viewBox="0 0 120 72" aria-hidden="true">
<g ref={net} className="ml-kickoff__net">
{REST.map((d, i) => <path key={i} d={d} />)}
</g>
<path className="ml-kickoff__frame" d="M4 71 V4 H116 V71" />
</svg>
<button type="button" className="ml-kickoff__btn" onClick={kick} aria-disabled={state !== "set"}>
<span ref={ball} className="ml-kickoff__ball ml-chrome" aria-hidden="true">
<span className="ml-chrome__skin"><BallSeams /></span>
</span>
<span className="ml-kickoff__label" aria-live="polite">{state === "scored" ? goalLabel : label}</span>
</button>
</div>
);
}
/*
Kick-off. Ball flight: --ml-dur-flight on a curl (WAAPI). Impact: 1100ms on one clock. The net pockets the
ball for 230ms and springs back over 700ms; the ball then falls 330ms, bounces once and rolls out.
Label: pops in with --ml-ease-settle. The ball is set again with a quick drop-in.
Reduced motion: no flight, the label swaps.
*/
.ml-kickoff {
position: relative;
width: 100%;
height: 100%;
min-height: 14rem;
display: grid;
grid-template-rows: 1fr auto;
padding: 1.5rem;
}
.ml-kickoff__goal {
justify-self: end;
width: min(46%, 11rem);
overflow: visible;
}
.ml-kickoff__frame { fill: none; stroke: var(--ml-ink); stroke-width: 3; stroke-linejoin: round; }
.ml-kickoff__net { fill: none; stroke: var(--ml-fg-muted); stroke-width: 0.75; stroke-linejoin: round; opacity: 0.6; }
.ml-kickoff__btn {
justify-self: start;
appearance: none;
border: 0;
display: inline-flex;
align-items: center;
gap: 0.65rem;
padding: 0.6rem 1.2rem 0.6rem 0.6rem;
border-radius: var(--ml-radius-control);
background: var(--ml-ink);
color: var(--ml-ink-fg);
font: inherit;
font-size: 0.8125rem;
font-weight: 500;
line-height: 1;
text-transform: uppercase;
cursor: pointer;
overflow: visible;
transition: color var(--ml-dur-quick) var(--ml-ease-out), transform var(--ml-dur-tap) var(--ml-ease-out);
}
.ml-kickoff__btn:active { transform: scale(0.97); }
/* Chrome on hover: the metal fades in under the label, a sheen crosses it once. */
.ml-kickoff__btn { position: relative; isolation: isolate; }
.ml-kickoff__btn::before {
content: "";
position: absolute;
inset: 0;
z-index: -1;
border-radius: inherit;
background: var(--ml-chrome-sheen), var(--ml-chrome);
background-size: 260% 100%, 100% 100%, 100% 100%; /* sheen, then the two chrome layers */
background-position: 115% 0, 0 0, 0 0;
box-shadow: var(--ml-chrome-edge);
opacity: 0;
transition: opacity var(--ml-dur-quick) var(--ml-ease-out), background-position 0s linear var(--ml-dur-quick);
}
.ml-kickoff__btn:hover { color: var(--ml-chrome-fg); }
.ml-kickoff__btn:hover::before {
opacity: 1;
background-position: -15% 0, 0 0, 0 0;
transition: opacity var(--ml-dur-quick) var(--ml-ease-out), background-position var(--ml-dur-flight) var(--ml-ease-out);
}
.ml-kickoff__btn:active::before { opacity: 1; background: var(--ml-chrome-press); }
.ml-kickoff__btn:focus-visible { outline: 2px solid var(--ml-focus); outline-offset: 3px; }
.ml-kickoff__btn[aria-disabled="true"] { cursor: default; }
.ml-kickoff__ball {
position: relative;
width: 22px;
height: 22px;
flex: none;
z-index: 1;
}
.ml-kickoff[data-state="set"] .ml-kickoff__ball {
animation: ml-kick-set var(--ml-dur-base) var(--ml-ease-settle) both;
}
.ml-kickoff__label { display: inline-block; min-width: 4.5em; }
.ml-kickoff[data-state="scored"] .ml-kickoff__label {
animation: ml-kick-goal var(--ml-dur-base) var(--ml-ease-settle) both;
}
@keyframes ml-kick-set { from { opacity: 0; transform: translateY(-10px) scale(0.6); } }
@keyframes ml-kick-goal { from { opacity: 0; transform: scale(0.6); } }
@media (prefers-reduced-motion: reduce) {
.ml-kickoff[data-state] .ml-kickoff__ball,
.ml-kickoff[data-state] .ml-kickoff__label { animation: none; }
}
