Boarding Pass
A boarding pass that keeps itself current — when gate or times change, only moved characters roll over, new values turn orange, and old ones stay underneath struck through.
Boarding Pass
A boarding pass that keeps itself current — when gate or times change, only moved characters roll over, new values turn orange, and old ones stay underneath struck through.
The pass displays flight details with airport codes, times, gate, boarding time, seat, and group. When information updates — like a gate change or delay — individual characters flip over like a departures board, the new value turns orange, and the old value appears underneath with a strikethrough. A status badge shows whether the flight is on-time, delayed, boarding, or experiencing a gate change, with an optional note below for additional context.
Installation
Install the component with the Craft-UI Blocks CLI — it drops boarding-pass.tsx into your project and wires up its runtime dependencies:
npx mvpblocks add boarding-passpnpm dlx mvpblocks add boarding-passyarn dlx mvpblocks add boarding-passbunx mvpblocks add boarding-passFile Structure
The CLI saves the component to your project's components/ui folder:
Import the default export from @/components/ui/boarding-pass. The prop type is exported as BoardingPassProps, and the data shape as Flight and FlightStatus.
Usage
BoardingPass is a client component and every prop is optional — with no props it renders a demo flight that cycles through gate changes, delays, and boarding status. Drop it into any card slot:
"use client";
import BoardingPass from "@/components/ui/boarding-pass";
export function FlightCard() {
return <BoardingPass />;
}Pass your own flight data with the flight prop to display real flight information:
const myFlight = {
airline: "Northwind",
number: "NW 214",
from: { code: "LIS", city: "Lisbon", time: "10:40" },
to: { code: "CPH", city: "Copenhagen", time: "15:05" },
date: "Thu, 12 Nov",
gate: "B12",
boards: "10:05",
seat: "14A",
group: "2",
passenger: "Maya Chen",
status: "on-time",
};
<BoardingPass flight={myFlight} />Update the flight object to trigger animations — only the characters that changed will flip over. Add a note to display additional information below the status badge:
const delayedFlight = {
...myFlight,
gate: "B31",
boards: "10:30",
from: { ...myFlight.from, time: "11:05" },
to: { ...myFlight.to, time: "15:30" },
status: "delayed",
note: "Delayed 25 min, late inbound aircraft",
};
<BoardingPass flight={delayedFlight} />Use className to adjust the card's width or spacing:
<BoardingPass flight={myFlight} className="max-w-md" />Theming
The card uses zinc tones with themed accents. The surface is rounded-3xl border-zinc-200 bg-white in light mode, inverting to dark:border-zinc-800 dark:bg-zinc-950. Text follows the theme: headings are text-zinc-900 (dark:text-zinc-100), labels are text-zinc-500 (dark:text-zinc-400), and secondary text is text-zinc-400 (dark:text-zinc-500).
The status badge changes color based on the flight status:
- On-time:
bg-emerald-50 text-emerald-700(dark:bg-emerald-500/10 dark:text-emerald-400) - Gate change:
bg-orange-50 text-orange-700(dark:bg-orange-500/10 dark:text-orange-400) - Delayed:
bg-red-50 text-red-700(dark:bg-red-500/10 dark:text-red-400) - Boarding:
bg-sky-50 text-sky-700(dark:bg-sky-500/10 dark:text-sky-400)
Changed values turn orange (text-orange-600 / dark:text-orange-400) and the struck-through previous value appears in muted zinc (text-zinc-400 / dark:text-zinc-500).
The tear line is created with radial gradient masks and a dashed border, with semicircular notches on either side. The barcode is procedurally generated from the passenger name and flight number.
Animations
- Flap flip: Each character that changes rolls over individually with a staggered delay (
60msper character) on a0.32sease-out, creating a departures board effect. - Color transition: Changed values transition to orange over
300msease-out, maintaining visibility for what just updated. - Strikethrough fade: The previous value fades in underneath with a
0.24sdelay after the new value settles, giving users time to see what changed. - Status badge: The status label pops in with a
0.22sease-out animation when the status changes. - Note text: Additional notes slide up and fade in when present, or fade out when removed.
- Reduced motion: When
prefers-reduced-motionis set, all animations are disabled and changes appear instantly.
How it works
The Flap component watches each character position in a string and only animates the characters that changed. It uses AnimatePresence with popLayout mode to smoothly exit the old character upward while the new one enters from above.
The Field component compares the current value with the previous one (tracked via usePrevious) and highlights changes with orange text. The old value is displayed underneath with AnimatePresence, fading in after a brief delay.
The barcode is deterministically generated using a linear congruential generator seeded by the passenger name and flight number, ensuring each pass gets a unique but stable pattern. Bars are drawn as SVG rectangles with randomized widths and gaps.
The tear line uses CSS mask composition to create semicircular notches that cut into the card border. A ResizeObserver tracks the tear line's position to keep the notches aligned as the card resizes. The notch outlines are drawn as separate SVG arcs positioned absolutely over the masked areas.
The demo mode cycles through four flight states every 3.2 seconds, showing on-time, gate change, delayed, and boarding statuses to demonstrate the animation system.
Props
Prop
Type
Flight Object
Prop
Type
Registry Bundle
Install the exact registry entry shown on the right when you want the component file and its declared runtime dependencies together. Dependencies: motion (for character flip animations), lucide-react (for the plane icon).
Contact
If you find any bug or issue, feel free to raise an issue.
Last updated on