Hologram Card
A holographic card for React: a faint iridescent sheen and a soft 1px rim that shift as the card tilts gently in 3D. Built with Motion springs and Tailwind CSS, for event passes, profile cards and collectibles.
- 3D tilt
- Iridescent foil
- Motion values
- Mouse only
- Reduced-motion safe
Access pass
Dusk Conf 2026
Mira Okafor
Speaker · All areas
#0042
import { Cpu } from "lucide-react";
import { HologramCard } from "@/components/dusk/techy/hologram-card";
export default function HologramCardDemo() {
return (
<HologramCard className="flex aspect-[1.586] w-full max-w-sm flex-col justify-between">
<div className="flex items-start justify-between">
<div>
<p className="text-xs text-white/50">Access pass</p>
<p className="mt-1 text-lg font-semibold text-white">Dusk Conf 2026</p>
</div>
<Cpu className="size-6 text-white/60" aria-hidden />
</div>
<div className="flex items-end justify-between">
<div>
<p className="text-sm font-medium text-white">Mira Okafor</p>
<p className="text-xs text-white/50">Speaker · All areas</p>
</div>
<p className="text-xs tabular-nums text-white/55">#0042</p>
</div>
</HologramCard>
);
}Installation
$ npx shadcn@latest add https://duskui.com/r/hologram-card.json1. Install the dependencies.
npm install motion2. Copy the source into
components/dusk/techy/hologram-card.tsx.hologram-card.tsx "use client"; import * as React from "react"; import { motion, useMotionTemplate, useMotionValue, useReducedMotion, useSpring, useTransform, type HTMLMotionProps, } from "motion/react"; import { cn } from "@/lib/utils"; export interface HologramCardProps extends Omit<HTMLMotionProps<"div">, "children"> { children?: React.ReactNode; /** Maximum tilt in degrees. 0 disables the tilt. */ maxTilt?: number; /** Show faint, static scanlines over the foil. */ scanlines?: boolean; } const spring = { stiffness: 180, damping: 20, mass: 0.6 }; const foil = "linear-gradient(115deg, #ff6ad5 0%, #8b5cf6 18%, #5ef2ff 34%, #7dffb3 50%, #fff27a 66%, #ff9a6a 82%, #ff6ad5 100%)"; const rim = "#ff6ad5, #8b5cf6, #5ef2ff, #7dffb3, #fff27a, #ff9a6a, #ff6ad5"; /** * A card with a subtle holographic foil: a faint iridescent sheen that shifts * as the card tilts toward the pointer, and a soft iridescent 1px rim. * * Pointer tracking uses motion values and springs, so it never re-renders. * It reacts to a mouse only (touch scrolls normally) and is fully static * with reduced motion. */ export function HologramCard({ children, maxTilt = 6, scanlines = false, className, style, onPointerMove, onPointerLeave, ...props }: HologramCardProps) { const reduceMotion = useReducedMotion(); // Pointer position over the card, 0–1 on both axes; 0.5 is the center. const px = useMotionValue(0.5); const py = useMotionValue(0.5); const hover = useMotionValue(0); const sx = useSpring(px, spring); const sy = useSpring(py, spring); const sHover = useSpring(hover, { stiffness: 160, damping: 26 }); const rotateX = useTransform(sy, [0, 1], [maxTilt, -maxTilt]); const rotateY = useTransform(sx, [0, 1], [-maxTilt, maxTilt]); const foilX = useTransform(sx, (v) => 15 + v * 70); const foilY = useTransform(sy, (v) => 15 + v * 70); const foilPosition = useMotionTemplate`0 0, ${foilX}% ${foilY}%`; const foilOpacity = useTransform(sHover, [0, 1], [0.06, 0.12]); const rimAngle = useTransform(sx, (v) => v * 240 + 60); const rimBackground = useMotionTemplate`conic-gradient(from ${rimAngle}deg, ${rim})`; const rimOpacity = useTransform(sHover, [0, 1], [0.2, 0.4]); const handleMove = (event: React.PointerEvent<HTMLDivElement>) => { onPointerMove?.(event); if (reduceMotion || event.pointerType !== "mouse") return; const el = event.currentTarget; const rect = el.getBoundingClientRect(); // Measure against the untransformed size around the (stable) center so the tilt can't feed back. const x = (event.clientX - (rect.left + rect.width / 2)) / el.offsetWidth + 0.5; const y = (event.clientY - (rect.top + rect.height / 2)) / el.offsetHeight + 0.5; px.set(Math.min(Math.max(x, 0), 1)); py.set(Math.min(Math.max(y, 0), 1)); hover.set(1); }; const handleLeave = (event: React.PointerEvent<HTMLDivElement>) => { onPointerLeave?.(event); px.set(0.5); py.set(0.5); hover.set(0); }; const layer = "pointer-events-none absolute inset-0 rounded-[inherit]"; const still = reduceMotion || maxTilt === 0; return ( <motion.div className={cn( "relative isolate rounded-xl border border-white/10 bg-card p-6 text-card-foreground shadow-lg", className )} style={{ transformPerspective: 900, rotateX: still ? 0 : rotateX, rotateY: still ? 0 : rotateY, ...style, }} onPointerMove={handleMove} onPointerLeave={handleLeave} {...props} > {/* Iridescent foil with fine diagonal etching. */} <motion.div aria-hidden className={cn(layer, "-z-10 mix-blend-screen")} style={{ backgroundImage: `repeating-linear-gradient(115deg, transparent 0 6px, rgb(255 255 255 / 0.05) 6px 7px), ${foil}`, backgroundSize: "100% 100%, 300% 300%", backgroundPosition: reduceMotion ? "0 0, 50% 50%" : foilPosition, opacity: reduceMotion ? 0.08 : foilOpacity, }} /> {/* Iridescent rim: the conic gradient is masked down to a 1px ring. */} <motion.div aria-hidden className={cn( layer, "-m-px p-px [mask-image:linear-gradient(#000_0_0),linear-gradient(#000_0_0)] [mask-clip:content-box,border-box] [mask-composite:exclude]" )} style={{ background: rimBackground, opacity: reduceMotion ? 0.25 : rimOpacity, }} /> {scanlines && ( <div aria-hidden className={cn(layer, "-z-10")} style={{ backgroundImage: "repeating-linear-gradient(to bottom, rgb(255 255 255 / 0.03) 0 1px, transparent 1px 3px)", }} /> )} {children} </motion.div> ); }
Usage
import { HologramCard } from "@/components/dusk/techy/hologram-card"
export function Pass() {
return (
<HologramCard className="w-80">
<p className="text-lg font-semibold">Dusk Conf 2026</p>
<p className="text-sm text-white/60">All-access pass</p>
</HologramCard>
)
}Examples
Profile card
The card is a plain container, so any content works: avatars, stats, badges.
Kai Nakamura
Open-source maintainer
- Commits
- 4,218
- Streak
- 132d
- Repos
- 38
import { HologramCard } from "@/components/dusk/techy/hologram-card";
const stats = [
{ label: "Commits", value: "4,218" },
{ label: "Streak", value: "132d" },
{ label: "Repos", value: "38" },
];
export default function HologramCardProfile() {
return (
<HologramCard className="w-full max-w-xs text-center">
<div className="mx-auto grid size-16 place-items-center rounded-full border border-white/15 bg-white/5 text-xl font-semibold text-white">
KN
</div>
<h3 className="mt-3 text-lg font-semibold text-white">Kai Nakamura</h3>
<p className="text-sm text-white/55">Open-source maintainer</p>
<dl className="mt-5 grid grid-cols-3 gap-2">
{stats.map((s) => (
<div key={s.label} className="rounded-lg border border-white/10 bg-black/20 py-2">
<dt className="text-[11px] text-white/55">{s.label}</dt>
<dd className="text-sm font-medium tabular-nums text-white">{s.value}</dd>
</div>
))}
</dl>
</HologramCard>
);
}Subtle & flat
Use a smaller maxTilt, or 0 for a flat card. scanlines adds faint static lines over the foil.
Scanlines
maxTilt=4 with faint static scanlines.
Flat foil
No tilt. The foil sheen still shifts with the pointer.
import { HologramCard } from "@/components/dusk/techy/hologram-card";
export default function HologramCardMinimal() {
return (
<>
<HologramCard maxTilt={4} scanlines className="w-56">
<p className="text-sm font-medium text-white">Scanlines</p>
<p className="mt-1 text-sm text-white/55">maxTilt=4 with faint static scanlines.</p>
</HologramCard>
<HologramCard maxTilt={0} className="w-56">
<p className="text-sm font-medium text-white">Flat foil</p>
<p className="mt-1 text-sm text-white/55">No tilt. The foil sheen still shifts with the pointer.</p>
</HologramCard>
</>
);
}API Reference
Accepts every motion.div prop. Your onPointerMove and onPointerLeave handlers still run; style is merged after the tilt.
| Prop | Type | Default | Description |
|---|---|---|---|
| maxTilt | number | 6 | Maximum tilt in degrees; 0 disables it. |
| scanlines | boolean | false | Show faint, static scanlines over the foil. |
| className | string | — | Merged onto the card; set width, padding and layout here. |
Accessibility
- Every effect layer is aria-hidden and pointer-events-none; only your content is exposed to assistive tech.
- Effects sit behind the content at low opacity, so text contrast is preserved.
- Tilt follows a mouse only; touch users scroll normally without the card moving.
- With prefers-reduced-motion the card is fully static: no tilt and no foil shift.