Miss. Train. Move.

Relay

Steps, page changes. One step hands the baton to the next.

Step 1 of 3

Pick your team

North FC · Under-14s

Sport
Athletics
Move
One step hands the baton to the next.
For
Steps, page changes

handover at 35% · leans, settles 560ms · reduced: cross-fade

01 Install

Terminal
npx shadcn@latest add https://moveui-red.vercel.app/r/relay.json

It brings the tokens with it. The first time, import the tokens once in your root layout:

app/layout.tsx
import "@/components/moveui/tokens.css";

Not using shadcn? Copy the files below into components/moveui/, and tokens.css next to them.

02 Use it

Example
import { Relay, RelayBaton } from "@/components/moveui/relay/relay";

<RelayBaton step={step} count={3} />
<Relay step={step}>
  <TeamStep />
  <KitStep />
  <ConfirmStep />
</Relay>
<button onClick={() => setStep(step + 1)}>Next</button>

03 Or ask your agent

Paste this into Claude Code, Cursor or any coding agent. It installs the piece and wires it in.

Prompt
Add the Move UI "Relay" piece to this project. It's for: Steps, page changes.

1. Install it: npx shadcn@latest add https://moveui-red.vercel.app/r/relay.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 { Relay, RelayBaton } from "@/components/moveui/relay/relay";

<RelayBaton step={step} count={3} />
<Relay step={step}>
  <TeamStep />
  <KitStep />
  <ConfirmStep />
</Relay>
<button onClick={() => setStep(step + 1)}>Next</button>

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/relay

Want your agent to know the whole library and its motion rules? Add the Move UI skill to your project:

Terminal
npx shadcn@latest add https://moveui-red.vercel.app/r/skill.json

04 Code

components/moveui/relay/relay.tsx
"use client";

import { Children, useEffect, useRef, useState, type ReactNode } from "react";
import "./relay.css";

/**
 * Relay (athletics): one step hands the baton to the next. The outgoing step runs off leaning forward;
 * the incoming one starts before it has gone (the handover zone), leans in and straightens as it
 * settles. Going back runs the other way. Both sit in the same grid cell, so nothing jumps.
 * Pass the steps as children and the current index as `step`. Focus moves to the new step.
 * <RelayBaton> is the progress track whose baton slides to the current step.
 * Reduced motion: a quick cross-fade.
 */
type Props = { step: number; children: ReactNode; label?: (i: number, n: number) => string; className?: string };

export function Relay({ step, children, label = (i, n) => `Step ${i + 1} of ${n}`, className }: Props) {
  const steps = Children.toArray(children);
  const [run, setRun] = useState({ cur: step, prev: null as number | null, dir: 1, leg: 0 });
  // A new step: the current runner becomes the outgoing one (derived during render, no extra paint).
  if (step !== run.cur) setRun({ cur: step, prev: run.cur, dir: step > run.cur ? 1 : -1, leg: run.leg + 1 });

  const incoming = useRef<HTMLDivElement>(null);
  useEffect(() => {
    if (run.leg > 0) incoming.current?.focus({ preventScroll: true });
  }, [run.leg]);

  return (
    <div className={["ml-relay", className].filter(Boolean).join(" ")} style={{ ["--dir" as string]: run.dir }}>
      {run.prev !== null && run.prev !== run.cur && (
        <div
          key={`out-${run.leg}`}
          className="ml-relay__leg"
          data-leaving=""
          aria-hidden="true"
          inert
          onAnimationEnd={(e) => { if (e.target === e.currentTarget) setRun((r) => (r.leg === run.leg ? { ...r, prev: null } : r)); }}
        >
          {steps[run.prev]}
        </div>
      )}
      <div
        key={`in-${run.leg}`}
        ref={incoming}
        className="ml-relay__leg"
        data-entering={run.leg > 0 ? "" : undefined}
        role="group"
        aria-label={label(run.cur, steps.length)}
        tabIndex={-1}
      >
        {steps[run.cur]}
      </div>
    </div>
  );
}

/** The track: n legs, the baton slides to the current one. Decorative; pair it with real step text. */
export function RelayBaton({ step, count, className }: { step: number; count: number; className?: string }) {
  return (
    <div className={["ml-baton", className].filter(Boolean).join(" ")} style={{ ["--n" as string]: count, ["--i" as string]: step }} aria-hidden="true">
      {Array.from({ length: count }, (_, i) => <span key={i} data-done={i < step ? "" : undefined} />)}
      <b />
    </div>
  );
}
components/moveui/relay/relay.css
/*
  Relay. Out: runs off over --ml-dur-base, leaning forward (skew), easing in like a runner pulling away.
  In: starts after 35% of that (the handover), comes in from the other side leaning, and straightens
  with --ml-ease-settle over --ml-dur-travel. --dir is 1 going forward, -1 going back.
  Baton: slides along the track with --ml-ease-settle, stretching a little while it moves.
*/
.ml-relay { display: grid; }
.ml-relay__leg { grid-area: 1 / 1; min-width: 0; }
.ml-relay__leg:focus { outline: none; }
.ml-relay__leg[data-leaving] {
  pointer-events: none;
  animation: ml-relay-out var(--ml-dur-base) cubic-bezier(0.5, 0, 0.9, 0.6) both;
}
.ml-relay__leg[data-entering] {
  animation: ml-relay-in var(--ml-dur-travel) var(--ml-ease-settle) calc(var(--ml-dur-base) * 0.35) both;
}
@keyframes ml-relay-out {
  to { opacity: 0; transform: translateX(calc(var(--dir) * -48px)) skewX(calc(var(--dir) * -6deg)); }
}
@keyframes ml-relay-in {
  from { opacity: 0; transform: translateX(calc(var(--dir) * 48px)) skewX(calc(var(--dir) * -6deg)); }
  40% { opacity: 1; }
}

.ml-baton { position: relative; display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 4px; height: 4px; }
.ml-baton span { border-radius: var(--ml-radius); background: var(--ml-line); transition: background-color var(--ml-dur-base) var(--ml-ease-out); }
.ml-baton span[data-done] { background: var(--ml-fg-muted); }
.ml-baton b {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: calc((100% - (var(--n) - 1) * 4px) / var(--n));
  border-radius: var(--ml-radius);
  background: var(--ml-ink);
  transform: translateX(calc(var(--i) * (100% + 4px)));
  transition: transform var(--ml-dur-travel) var(--ml-ease-settle);
}

@media (prefers-reduced-motion: reduce) {
  @keyframes ml-relay-out { to { opacity: 0; } }
  @keyframes ml-relay-in { from { opacity: 0; } }
}