Design.dev design.dev
Cards · Component Template

Holographic Card

A season pass on diffraction foil. Tilt it and a band of color travels across the face, glitter fires, and meteors slide along their tracks. Flick it to spin it over.

Live demo

Output of this prompt · Claude Fable 5.2 · WebGL + CSS 3D

Move across the card to tilt the foil. Drag sideways and let go to flip it.

The Prompt 967 words

Build a collectible holographic card: a season pass for an observatory that hangs in 3D, tilts under the pointer, spins over when thrown, and whose foil is computed, not painted. A fragment shader works out, for every pixel, the angle between the eye, a lamp and the card, and from that decides the color the foil throws, which grains of glitter fire and where the meteors are on their tracks. Turn it and a band of color travels across the face exactly as it does on real diffraction foil. Match my project's existing stack, conventions, and design tokens. If there are none, output a single HTML file with inline CSS and JavaScript and zero dependencies. One small WebGL canvas inside a CSS 3D card: no library, no textures, no images.

LOOK
- Page #05060B, text #EEF0F8. ui-sans-serif, system-ui. A three-column stage, vertically centered: copy on the left, the card in the middle, controls on the right; one column under 900px.
- Left: h1 "A ticket you will keep in a drawer for twenty years." at clamp(34px, 3.8vw, 60px), weight 640, letter-spacing -0.045em, and two lines of copy.
- Right: a glass dock labeled "Foil" with a three-way switch (Prism, Aurora, Gold) whose thumb slides on a spring using :has(), and one line of instruction.
- Behind the card a wide radial glow, and under it a blurred ellipse of light, both in the current foil's color: #7A8CFF, #3FE0C0 or #F0B24A. Register the color with @property so it crossfades over 700ms.
- Film grain at 9%.

THE CARD
- A button, min(350px, 76vw, 46vh) wide, aspect 5:7, radius 22px, transform-style: preserve-3d, perspective 1300px on its parent. Rotation comes from two custom properties, --rx and --ry, in degrees.
- Two faces with backface-visibility hidden. Front: the canvas, with real text on top (top row "Calder Ridge Observatory" and "No. 0412"; bottom "NIGHT PASS" in tracked capitals sized in cqw units, and "Perseid season, August 9 to 14, 2026. Admits one, dusk to dawn."). Back: entry instructions and a barcode drawn with a repeating gradient.

THE FOIL SHADER
- Inputs: tilt (the sines of the two rotation angles of whichever face is toward the viewer) and a finish value from 0 to 2.
- Eye V = normalize(-tilt.x, tilt.y, 1). Lamp L = normalize(0.35 - 1.6 tilt.x, 0.55 + 1.6 tilt.y, 0.75). Half-vector H = normalize(L + V). Everything below is a function of H.
- Night: a deep blue vertical gradient with a vignette.
- Stars: three sheets of hashed points at 26, 15 and 8 cells across, each offset by tilt x 0.02, 0.06 and 0.12, so they slide over one another with real parallax.
- The radiant sits upper right. Around it: fine concentric grooves (sin(150 x distance), thresholded, fading out by 0.62). From it: eleven spokes, about half of which carry a meteor, a thin streak with a bright head whose position along the spoke is fract(seed + 1.4 tilt.x + 0.9 tilt.y + a slow drift). Tilting the card moves the meteors.
- A band of fine diagonal lines above the title and a thin frame inset from the edge.
- Color: one "tone" per pixel = dot(direction from the radiant, H.xy) x 2.2 + distance x 1.6 + dot(H.xy, (1.7, 1.1)) x 2. Each finish maps tone to color differently: Prism is a full cosine rainbow; Aurora swings between green-teal and violet with a pink flare; Gold runs from dark brass to pale gold.
- Everything foil (stars, meteors, grooves, band, frame) is multiplied by that color and by a sweep: smoothstep(0.2, 1, 0.5 + 0.5 sin(dot(p, (2.6, 3.4)) + 10 tilt.x + 8 tilt.y)), with a floor of 10%. So most of the card is nearly dark and one band is brilliant, and the band moves as the card turns.
- Glitter: a 90 by 126 grid. Each cell is a tiny round mirror with its own random facing; it fires only when dot(facing, H) is almost 1 (power 240), in white mixed with its own hue. Half the cells are empty.
- A soft specular spot for the lamp itself, sliding across the surface.

MOTION
- Hovering: the card leans to face the pointer, up to about 17 degrees up and down and 22 left and right, on a spring (stiffness 90 and 70, damping 13 and 11).
- Left alone: it sways slowly on two sine waves so the foil keeps catching the light.
- Dragging sideways turns it directly, 0.55 degrees per pixel. On release it keeps its speed and the spring carries it to whichever face that speed will reach, so a flick spins it over and a slow drag falls back.
- A press without dragging, or Enter, turns it over. Arrow keys tilt it.
- Finish changes crossfade in the shader over about a fifth of a second.
- Load: the card and both columns sharpen from a blur and settle on a CSS spring.

BEHAVIOR
- Canvas at up to 2x device pixels; drop resolution in steps if frames run long; pause when hidden or off screen.
- Without WebGL, fill the front with a conic gradient and keep everything else.

ACCESSIBILITY
- The card is a button with aria-pressed for which face is showing and a label that explains dragging and Enter. All text on it is real DOM text.
- The foil switch is three radio inputs in a labeled group.
- prefers-reduced-motion: no idle sway; the card moves only in response to the pointer or keys.

NEVER
- No rainbow gradient laid flat across the whole card. Color must depend on angle.
- No image textures, sparkle GIFs or SVG noise.
- No tilt that follows the pointer without easing.
- No foil on the text itself; the lettering stays white and readable.
  1. CopyThe full prompt, one click.
  2. PasteInto Cursor, Claude Code, or any agent.
  3. CompareAgainst the live demo above.
Holographic Card
Copied to clipboard