DHxWhy

Baggage Carousel Hero

Heroes 7

About

Baggage Carousel Hero for React and Tailwind CSS (shadcn/ui): an airport-inspired storefront with eight real-time 3D cases. A finite feeder introduces new arrivals onto a continuously turning belt. Hover or keyboard focus reveals a moving price tag. Select a case to lift it above the blurred airport, inspect both sides, choose an available colour and use your app’s purchase action. Closing returns it to the same belt position. Optional brand, navigation, announcement, cart count, collection CTA and purchase note make the storefront reusable. Keyboard navigation, a trapped detail dialog and reduced motion are supported. The included LANDSIDE demo uses fictional products, prices, stock and shipping policies; its bag is local demo state. Configure plateUrl, backdropUrl and modelUrl for your hosted assets. Requires React and three.js.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Baggage Carousel Hero to your project and fits it to your theme.

Code

How Baggage Carousel Hero is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

import { useEffect, useRef, useState } from "react";
import { BaggageCarouselLive, DEFAULT_ITEMS, type BaggageItem } from "@/components/ui/baggage-carousel-live";

// Products, prices, stock and shopping policies are fictional demonstration data.
// Swatches are sampled from the lit front shell at the desktop quick-view pose.
const measuredSwatches: Record<string, string> = {"orange": "rgb(196,113,29)", "red": "rgb(163,19,25)", "green": "rgb(136,147,124)", "yellow": "rgb(211,183,132)", "blue": "rgb(61,91,111)", "graphite": "rgb(74,78,84)", "ivory": "rgb(169,158,148)", "teal": "rgb(38,145,156)"};
const shopItems: BaggageItem[] = DEFAULT_ITEMS.map(item => ({ ...item,
  name: ({teal:"Terrace Cabin",graphite:"Atlas Check",ivory:"Facet Medium"} as Record<string,string>)[item.id] ?? item.name,
  group: ({orange:"terrace",teal:"terrace",red:"atlas",graphite:"atlas",green:"facet",ivory:"facet"} as Record<string,string>)[item.id],
  colorName: ({orange:"Amber",red:"Oxblood",green:"Sage",yellow:"Sand",blue:"Navy",graphite:"Graphite",ivory:"Ivory",teal:"Teal"} as Record<string,string>)[item.id],
  swatch: measuredSwatches[item.id],
  ...({green:{color:[138,154,128]},yellow:{color:[194,168,120]},blue:{color:[43,58,85]},orange:{stock:3},teal:{stock:2}} as Record<string,Partial<BaggageItem>>)[item.id],
}));
const countWord = ["Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve"][shopItems.length] ?? String(shopItems.length);
const priceOf = (item: BaggageItem) => Number((item.price ?? "").replace(/[^0-9.]/g, ""));
const money = new Intl.NumberFormat("en-US", {style:"currency",currency:"USD",maximumFractionDigits:0});
const shopSubtitle = `${countWord} hard-shell cases, from ${money.format(Math.min(...shopItems.map(priceOf)))}. Pick one off the belt for a closer look.`;
type BagLine = { id: string; quantity: number };
export default function BaggageCarouselLiveDemo({ autoplay = true, debug }: { autoplay?: boolean; debug?: Record<string, string> }) {
  const root = useRef(null as HTMLDivElement | null);
  const sheet = useRef(null as HTMLDivElement | null);
  const [lines, setLines] = useState([] as BagLine[]);
  const [bagOpen, setBagOpen] = useState(false);
  const count = lines.reduce((sum, line) => sum + line.quantity, 0);
  const subtotal = lines.reduce((sum, line) => sum + priceOf(shopItems.find(item => item.id === line.id)!) * line.quantity, 0);
  const add = (item: BaggageItem) => setLines(old => old.some(line => line.id === item.id) ? old.map(line => line.id === item.id ? { ...line, quantity: line.quantity + 1 } : line) : [...old, { id: item.id, quantity: 1 }]);
  const change = (id: string, delta: number) => setLines(old => old.flatMap(line => line.id !== id ? [line] : line.quantity + delta > 0 ? [{ ...line, quantity: line.quantity + delta }] : []));
  const closeBag = () => { setBagOpen(false); root.current?.querySelector<HTMLElement>('[data-ui="cart"]')?.focus({ preventScroll: true }); };
  useEffect(() => { if (bagOpen) sheet.current?.querySelector<HTMLElement>("[data-autofocus]")?.focus({ preventScroll: true }); }, [bagOpen]);
  return <div ref={root} id="new-arrivals" className="relative w-full">
    <BaggageCarouselLive autoplay={autoplay} debug={debug} items={shopItems}
      brand={{name:"LANDSIDE",href:"#new-arrivals"}}
      nav={[{label:"New arrivals",href:"#new-arrivals"},{label:"Carry-on",href:"#new-arrivals"},{label:"Check-in",href:"#new-arrivals"},{label:"Accessories",href:"#new-arrivals"}]}
      announcement="Free shipping on every case · 100-day returns"
      onSelect={() => setBagOpen(false)} cartCount={count} onCartClick={() => setBagOpen(true)}
      eyebrow="Belt 3 · Now arriving" title="Just landed." subtitle={shopSubtitle}
      cta={{label:"Shop new arrivals",variant:"button"}} shelf={{title:"New arrivals"}} actionLabel="Add to bag" onAction={add} purchaseNote="Free shipping · 100-day returns"
      plateAlt="A stainless steel airport carousel displaying new luggage beneath a blue New Arrivals sign."
      plateUrl="https://cdn.21st.dev/assets/mirror/3e/3e818ec0cff52188eddd7ebe978f3ff35502ee2877af053e4f37293a9b1d782e.webp" backdropUrl="https://cdn.21st.dev/assets/mirror/f6/f66992456ad21511f339bb50761e14402716d3e6bbb0ca07d01f8183b9a0da99.webp" modelUrl="https://pub-6f58b3de73d94592b51ec6b803788661.r2.dev/r1101/carousellive/carouselmulti.bin" />
    {bagOpen && <div data-slot="demo-bag-layer" className="absolute inset-0 z-30">
      <div aria-hidden="true" className="absolute inset-0 bg-black/30" onClick={closeBag} />
      <div ref={sheet} role="dialog" aria-modal="true" aria-labelledby="demo-bag-title" data-slot="demo-shopping-bag" className="absolute inset-y-0 right-0 flex w-full max-w-[400px] flex-col bg-background text-foreground shadow-xl" onKeyDown={event => {
        if (event.key === "Escape") { event.preventDefault(); event.stopPropagation(); closeBag(); return; }
        if (event.key !== "Tab") return; const controls = [...event.currentTarget.querySelectorAll<HTMLButtonElement>("button:not(:disabled)")], first = controls[0], last = controls.at(-1);
        if (event.shiftKey && document.activeElement === first) { event.preventDefault(); last?.focus(); } else if (!event.shiftKey && document.activeElement === last) { event.preventDefault(); first?.focus(); } }}>
        <div className="flex items-center justify-between border-b border-border px-6 py-5"><h2 id="demo-bag-title" className="text-lg font-medium">Your bag{count > 0 && <span className="text-muted-foreground"> ({count})</span>}</h2><button type="button" data-autofocus className="text-xs text-muted-foreground hover:text-foreground" onClick={closeBag}>Close</button></div>
        {lines.length > 0 ? <>
          <ul className="flex-1 overflow-y-auto px-6">{lines.map(line => { const item = shopItems.find(entry => entry.id === line.id)!, label = `${item.name}, ${item.colorName}`; return <li key={line.id} data-slot="demo-bag-line" data-line-id={line.id} className="flex items-start gap-4 border-b border-border py-5">
            <span aria-hidden="true" className="mt-0.5 size-10 shrink-0 rounded-full border border-border" style={{ background: item.swatch }} />
            <div className="min-w-0 flex-1"><p className="text-sm font-medium">{item.name}</p><p className="text-xs text-muted-foreground">{item.colorName}</p>
              <div className="mt-3 flex items-center gap-4 text-xs"><div className="inline-flex items-center rounded-full border border-border"><button type="button" aria-label={`One fewer ${label}`} className="px-3 py-1" onClick={() => change(line.id, -1)}>−</button><span data-slot="demo-bag-quantity" className="min-w-4 text-center tabular-nums">{line.quantity}</span><button type="button" aria-label={`One more ${label}`} className="px-3 py-1" onClick={() => change(line.id, 1)}>+</button></div><button type="button" aria-label={`Remove ${label}`} className="text-muted-foreground underline underline-offset-2 hover:text-foreground" onClick={() => change(line.id, -line.quantity)}>Remove</button></div></div>
            <p className="text-sm tabular-nums">{money.format(priceOf(item) * line.quantity)}</p>
          </li>; })}</ul>
          <div className="border-t border-border px-6 py-5"><div className="flex justify-between text-sm"><span>Subtotal</span><span data-slot="demo-bag-subtotal" className="tabular-nums">{money.format(subtotal)}</span></div><button type="button" disabled className="mt-4 w-full rounded-full bg-foreground px-5 py-3 text-sm text-background opacity-40">Checkout</button><p className="mt-2 text-center text-xs text-muted-foreground">Demo store · no payment</p><button type="button" className="mt-3 w-full text-xs underline underline-offset-2" onClick={closeBag}>Continue shopping</button></div>
        </> : <div className="flex flex-1 flex-col items-start gap-4 px-6 py-8"><p className="text-sm">Your bag is empty.</p><button type="button" className="text-sm underline underline-offset-2" onClick={closeBag}>Continue shopping</button></div>}
      </div>
    </div>}
  </div>;
}

Dependencies

More by DHxWhy

View all
  • Product Rail Gallery – Fashion Store Hero Section

    Product Rail Gallery – Fashion Store Hero Section

    2.7K
  • Sushi Conveyor Belt Menu – Restaurant Hero Section

    Sushi Conveyor Belt Menu – Restaurant Hero Section

    1.2K
  • Team Lanyard Rail – Meet the Team Section with Flip Badges

    Team Lanyard Rail – Meet the Team Section with Flip Badges

    1.2K
  • Skateboard Deck Rail Gallery – Skate Shop Hero Section

    Skateboard Deck Rail Gallery – Skate Shop Hero Section

    605
  • Picture Rail Image Gallery – Art Print Shop Hero Section

    Picture Rail Image Gallery – Art Print Shop Hero Section

    421
  • Sun Moon Dark Mode Theme Toggle

    Sun Moon Dark Mode Theme Toggle

    382
  • World Testimonials Globe – Social Proof Hero Section

    World Testimonials Globe – Social Proof Hero Section

    326
  • Pendant Lamp Rail Gallery – Lighting Store Hero Section

    Pendant Lamp Rail Gallery – Lighting Store Hero Section

    323

More in Heroes

View all
  • Responsive Hero Banner

    Responsive Hero Banner

    2.1K
  • Hero

    Hero

    1.3K
  • SaaS Template

    SaaS Template

    2.6K
  • Hero 03

    Hero 03

    367
  • Centered Hero with Image Fan

    Centered Hero with Image Fan

    1.1K
  • Editorial Collage Hero

    Editorial Collage Hero

    493
  • HeroSectionWithGradient

    HeroSectionWithGradient

    378
  • Aero Hero-3

    Aero Hero-3

    611