Skip to content

Expandable Card

A spring-driven card that expands in place with layout animation.

CSS 3DTypeScriptLight + AMOLED
Example.tsx
import { Cards3D } from "@/components/3d/cards";

export default function Example() {
  return (
    <div style={{ height: 420 }}>
      <Cards3D
        variant="expandable"
        theme="light"
      />
    </div>
  );
}

Deps: framer-motion, lucide-react

Installation

Install the runtime dependencies, then copy the component module (and the shared 3D core when the component uses WebGL).

terminal
npm install framer-motion lucide-react

# Copy the component module
cp -r src/components/3d/cards <your-project>/src/components/3d/cards

Dependencies: framer-motion, lucide-react

Usage

Every category module exposes one typed component. Pick an implementation with variant and pass props grouped by concern.

Example.tsx
import { Cards3D } from "@/components/3d/cards";

export default function Example() {
  return (
    <div style={{ height: 420 }}>
      <Cards3D
        variant="expandable"
        theme="light"
      />
    </div>
  );
}

React implementation

With every prop set explicitly. The complete, copyable source of src/components/3d/cards/index.tsx is available in the playground’s Source tab.

Example.tsx
import { Cards3D } from "@/components/3d/cards";

export default function Example() {
  return (
    <div style={{ height: 420 }}>
      <Cards3D
        variant="expandable"
        theme="amoled"
        title="Depth Study No. 4"
        subtitle="A quiet exploration of light and space."
        accent="#5255ff"
        tilt={12}
        perspective={1000}
        glare
        speed={1}
        elevation={24}
        radius={8}
        reducedMotion={false}
      />
    </div>
  );
}

Next.js implementation

This component is DOM based, but it is still code-split with next/dynamic so interaction code ships only where it's used.

app/expandable-card/page.tsx
// app/expandable-card/page.tsx  (Next.js App Router)
"use client";

import dynamic from "next/dynamic";

// Heavy interactive code is split into its own chunk.
const Cards3D = dynamic(
  () => import("@/components/3d/cards").then((m) => m.Cards3D),
  { ssr: false, loading: () => <div aria-busy="true" style={{ height: 420 }} /> },
);

export default function Page() {
  return (
    <main>
      <div style={{ height: 420 }}>
        <Cards3D
          variant="expandable"
          theme="light"
        />
      </div>
    </main>
  );
}

TypeScript interfaces

ExpandableCard.types.ts
export type Theme = "light" | "amoled";

export interface ExpandableCardProps {
  /** Which 3D Cards implementation to render */
  variant: "expandable";
  theme: Theme;

  /* Content */
  title?: string; // default "Depth Study No. 4"
  subtitle?: string; // default "A quiet exploration of light and space."

  /* Visual */
  accent?: string; // default "#5255ff"
  glare?: boolean; // default true
  elevation?: number; // 0–48, default 24
  radius?: number; // 0–24, default 8

  /* Interaction */
  tilt?: number; // 0–30, default 12

  /* Camera */
  perspective?: number; // 400–2000, default 1000

  /* Animation */
  speed?: number; // 0.3–3, default 1

  /* Accessibility */
  reducedMotion?: boolean; // default false
}

Props reference

PropTypeDefaultGroupDescription
variant"expandable"—CoreSelects the implementation.
theme"light" | "amoled"—CoreThemes surfaces, materials and lighting.
titlestring"Depth Study No. 4"ContentTitle
subtitlestring"A quiet exploration of light and space."ContentSubtitle
accentstring (hex)"#5255ff"VisualAccent
tiltnumber12InteractionTilt / parallax strength (°) (0 – 30)
perspectivenumber1000CameraPerspective (px) (400 – 2000)
glarebooleantrueVisualGlare highlight
speednumber1AnimationSpring speed (0.3 – 3)
elevationnumber24VisualElevation (px) (0 – 48)
radiusnumber8VisualCorner radius (px) (0 – 24)
reducedMotionbooleanfalseAccessibilityForce reduced motion

Customization

Colour props accept any hex string. Content props accept plain strings. Every value shown in the playground maps 1:1 to a prop, so you can design visually and copy the generated code. Use Share to send a pre-configured link or Export to download the configuration JSON.

Customized.tsx
import { Cards3D } from "@/components/3d/cards";

export default function Example() {
  return (
    <div style={{ height: 420 }}>
      <Cards3D
        variant="expandable"
        theme="light"
        accent="#ff5a36"
      />
    </div>
  );
}

Animation settings

  • tiltTilt / parallax strength (°) · 0–30
  • speedSpring speed · 0.3–3

All motion is suspended when prefers-reduced-motion is on.

Theme support

Pass theme="light" or theme="amoled". Surfaces, borders, shadows and text switch via CSS variables (--bg, --card, --fg, --border, --accent). AMOLED uses true #000000. Use the theme switch in the playground toolbar to preview both.

Responsive behavior

The component fills its parent, so size it with the container. Use the playground’s desktop / tablet / mobile selector to test. Layouts use fluid widths and container-relative sizing.

Accessibility notes

  • — Interactive cards use real buttons, links or form controls, never click handlers on divs.
  • — Decorative layers are aria-hidden; 3D tilt is disabled for reduced-motion users.
  • — Flip and expand cards expose aria-pressed / aria-expanded.

Performance notes

  • — Tilt uses transform-only animation, which stays on the compositor.
  • — Springs are driven by motion values, so pointer movement doesn't trigger React renders.
  • — Artwork is generated SVG — zero network requests.