Command Palette

Search for a command to run...

0GitHub stars
Components

Spatial card carousel

A 3D orbital card showcase that keeps one editorial card centered in crisp focus while surrounding satellite cards drift across layered Z-depths, supporting light/dark themes, pointer tilt, and keyboard navigation.

Loading…
Dependencies (1)

Overview and background

The spatial card carousel introduces an orbital spatial stage where an active editorial card commands center focus at Z = 0px, while surrounding satellite cards drift gracefully across layered Z-depths ranging down to -270px. By keeping the active hero element anchored at true Z = 0, the browser avoids subpixel texture degradation, ensuring razor-sharp typography and vector clarity.

Satellite card coordinates follow a pre-calculated 10-slot orbital spatial distribution:

Slot(i) = [x_pos, y_pos, z_depth, scale, rot_x, rot_y, rot_z, opacity, blur]

where scale represents compression down to 0.26, rotation defines 3D Euler angles, opacity sets atmospheric attenuation, and blur applies subtle depth filtering. Cursor and pointer movement translates through zero-rerender GPU springs (useMotionValue, useSpring, useTransform), applying smooth interactive tilt across the stage (-6° to +6°) without re-rendering React fiber nodes. Autonomous secondary ambient loops gently bob satellite cards along a sinusoidal (±6px) curve on individual asynchronous cadences, maintaining an organic, floating spatial feel.

Features

  • True 3D orbital staging with layered depth planes (Z = 0px to -270px) and optical blur attenuation.
  • Zero-rerender cursor parallax using direct hardware-accelerated motion values and spring damping.
  • Independent ambient floating motion on satellite cards running on isolated keyframes to avoid jarring transitions.
  • Interactive multi-modal controls: smooth wheel and trackpad scrubbing, pointer dragging, card click-to-focus, and keyboard navigation.
  • Autonomous autoplay engine with pause-on-hover and instant interaction synchronization.
  • Full theme flexibility supporting dark, light, and adaptive system aesthetics.

Use cases

  • Editorial lookbooks, fashion campaigns, and brand identity showcase galleries.
  • Interactive product ecosystem visualizers displaying features orbiting a central core platform.
  • High-concept landing page heroes featuring brand artifacts, logos, and graphic design posters.
  • Design portfolio case study archives with deep spatial presentation.

Installation

pnpm dlx shadcn@latest add @abushaidislam/spatial-card-carousel

Usage

import SpatialCardCarousel, {
  type SpatialCardItem,
} from "@/components/spatial-card-carousel"
const SHOWCASE_ITEMS: SpatialCardItem[] = [
  {
    id: "item-1",
    title: "Monochrome Profile",
    subtitle: "Identity Study 01",
    image: "/images/study-01.jpg",
  },
  {
    id: "item-2",
    title: "Organic Pulse Grid",
    subtitle: "System Pattern",
    image: "/images/pattern-02.jpg",
  },
  {
    id: "item-3",
    title: "Beacon Glyph",
    subtitle: "Mark Architecture",
    image: "/images/glyph-03.jpg",
  },
]
 
export function ShowcaseExample() {
  return (
    <SpatialCardCarousel
      items={SHOWCASE_ITEMS}
      theme="auto"
      autoPlay={true}
      interval={2800}
      pauseOnHover={true}
      onActiveChange={(index, item) => console.log("Active item:", item.title)}
    />
  )
}

Composition

SpatialCardCarousel (region, role="carousel", perspective: 1500px)
├── Screen Reader Announcer (aria-live="polite", sr-only)
└── motion.div (orbital stage, preserve-3d, pointer tilt)
    └── motion.button (satellite/hero card, slot spring physics)
        └── motion.div (ambient float layer, sinusoidal bobbing)
            ├── renderContent() (custom JSX)
            ├── img (image cover with object-cover)
            └── fallback card (typography & subtitle)

API reference

SpatialCardCarouselProps

PropTypeDefaultDescription
itemsSpatialCardItem[]defaultItemsArray of spatial cards containing title, subtitle, image, or custom renderContent.
theme"auto" | "light" | "dark""auto"Color scheme styling applied to the orbital stage, card borders, and shadow rings.
autoPlaybooleantrueWhether the carousel automatically advances along the orbital path at set intervals.
intervalnumber2400Duration in milliseconds between autoplay steps (clamped at minimum 900ms).
pauseOnHoverbooleantruePauses the autoplay timer when a pointer hovers anywhere inside the stage area.
initialIndexnumber0Zero-based index of the card centered in the hero slot upon mounting.
onActiveChange(index: number, item: SpatialCardItem) => voidundefinedCallback fired whenever the focused hero card index transitions.
ariaLabelstring"3D spatial card showcase"Accessible description applied to the carousel landmark region.

SpatialCardItem

PropertyTypeDescription
idstringUnique identifier for persistent React key rendering.
titlestringTitle of the card used in accessibility announcements and default card faces.
subtitlestringOptional auxiliary descriptor displayed beneath the title.
imagestringOptional URL to a photography or visual asset displayed across the card surface.
imageAltstringOptional alt text for image assets (defaults to title).
renderContent() => ReactNodeOptional custom render function providing bespoke JSX content inside the card canvas.

Accessibility

  • Polite live regions: A dedicated .sr-only container with aria-live="polite" announces active card index changes (e.g. Showing Monochrome Profile (1 of 10)) without interrupting ongoing screen reader speech.
  • Direct card controls: Each card is rendered as a keyboard-focusable <button> element with clear contextual descriptions distinguishing between active advance triggers and background focus triggers.
  • Keyboard navigation: Supporting ArrowRight and ArrowDown to orbit forward, and ArrowLeft and ArrowUp to orbit backward.
  • Reduced motion handling: When prefers-reduced-motion is enabled, 3D Z-translation, Euler tilt rotations, and orbital spring velocities are replaced with gentle 2D planar slides and reduced opacities.

Frequently asked questions

Does the 3D mouse parallax trigger React re-renders?

No. The cursor tilt utilizes Framer Motion / Motion useMotionValue and useTransform connected directly to the DOM node's inline transform matrix via CSS style attributes. This executes entirely on the compositor thread with zero React re-render cycles during mouse moves.

How are touch gestures handled on mobile devices?

The stage listens to pointer down, move, and up events with touch-pan-y styling. Horizontal and vertical swipes exceeding 36px seamlessly step the carousel in the corresponding direction, while dragging allows immediate flick exploration.

Can cards render custom interactive components or video?

Yes. Use the renderContent callback property in SpatialCardItem to render custom interactive elements, SVG illustrations, or looping video tags. When using videos, ensure muted playback and reduced-motion considerations for satellite cards.

License and usage

  • Free to use and modify in both personal and commercial projects.
  • Attribution is appreciated but not required.
  • Released under the MIT License.

Was this helpful?

Command Palette

Search for a command to run...