3D Tilt Card for React
A 3D tilt card for React that leans toward the pointer, up to 8°, with a glare sliding across its glass surface on springs. Use it as a tilt effect for a hero tile or a featured product card that leans toward the pointer in 3D, with a glare and a rim light sliding across the glass.
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/tilt-card.jsonCard ending in 0815
Ada Lovelace, 09/29
TiltCardTiltCardLayer
Membership card
TiltCardLayer adds parallax: layers drift toward the pointer by their depth, so the card reads as layered without preserve-3d (which glass cannot use). A glare and a diagonal streak of light slide across the glass, and its edge catches the light nearest the pointer. Rest the pointer near a corner: the card holds still.
Card ending in 0815
Ada Lovelace · 09/29
import { Badge } from "@/components/sheenui/badge/badge";
import { TiltCard, TiltCardLayer } from "@/components/sheenui/tilt-card/tilt-card";
// Package build (after the first npm release, or a packed tarball): import { Badge, TiltCard, TiltCardLayer } from "@sheenui/theme";
import { Sparkles as SparkIcon } from "lucide-react";
// This example also uses badge: npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/badge.json
export function Example() {
return (
<TiltCard tint className="flex aspect-[1.586] w-full max-w-sm flex-col p-5 sm:p-6">
{/* Lights behind the content that drift the other way (negative depth). */}
<span aria-hidden className="pointer-events-none absolute inset-0 -z-10 overflow-hidden rounded-[inherit]">
<TiltCardLayer
depth={-14}
className="absolute -top-1/3 -end-1/4 aspect-square w-3/4 rounded-full [background:radial-gradient(closest-side,color-mix(in_oklab,var(--sheen-accent)_30%,transparent),transparent)]"
/>
<TiltCardLayer
depth={-8}
className="absolute -end-[15%] -bottom-1/2 aspect-square w-1/2 rounded-full [background:radial-gradient(closest-side,color-mix(in_oklab,var(--sheen-teal-500)_22%,transparent),transparent)]"
/>
</span>
<TiltCardLayer depth={6} className="flex items-start justify-between gap-3">
<span className="flex items-center gap-2 font-semibold">
<span aria-hidden className="sheen-fill grid size-8 place-items-center rounded-sheen-sm text-sheen-accent-fg [background-image:var(--sheen-accent-fill)]">
<SparkIcon /> {/* any 16px svg icon */}
</span>
Sheen Pay
</span>
<Badge tone="accent">Pro</Badge>
</TiltCardLayer>
{/* The chip */}
<TiltCardLayer depth={10} className="mt-3 sm:mt-5">
<span aria-hidden className="block h-8 w-11 rounded-md border border-sheen-border [background:linear-gradient(135deg,var(--sheen-chart-4),var(--sheen-chart-2))] opacity-80" />
</TiltCardLayer>
<TiltCardLayer depth={16} className="mt-auto flex flex-col gap-1">
<p className="font-sheen-mono text-base tracking-wider sm:text-lg">
<span className="sr-only">Card ending in 0815</span>
<span aria-hidden>4921 ···· ···· 0815</span>
</p>
<p className="text-sm text-sheen-fg-muted">Ada Lovelace · 09/29</p>
</TiltCardLayer>
</TiltCard>
);
}Files to copy
4 folders · 3 files · 3 packages
- From
theme/src/ components/tilt-card/hooks/{use-media-query.ts, use-preferences.ts}lib/cn.tsstyles/
- shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/tilt-card.jsonRegistry item: tilt-card. The styles need the Tailwind v4 glass UI setup.- The examples also use
components/badge/lib/warn-once.ts
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/badge.json- Packages
pnpm add clsx motion tailwind-merge
Pricing cards
A gentler tilt (maxTilt={5}) on cards that are links. The whole card is clickable through a stretched link, and keyboard focus shows a solid ring.
import { Badge } from "@/components/sheenui/badge/badge";
import { TiltCard } from "@/components/sheenui/tilt-card/tilt-card";
// Package build (after the first npm release, or a packed tarball): import { Badge, TiltCard } from "@sheenui/theme";
// This example also uses badge: npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/badge.json
export function Example() {
const plans = [
{ name: "Starter", price: "$0", note: "For side projects", href: "#starter" },
{ name: "Pro", price: "$24", note: "For growing teams", href: "#pro", tint: true },
{ name: "Scale", price: "$79", note: "For serious traffic", href: "#scale" },
];
return (
<ul className="grid w-full gap-4 sm:grid-cols-3">
{plans.map((plan) => (
<li key={plan.name}>
<TiltCard
maxTilt={5}
tint={plan.tint}
className="relative flex flex-col gap-2 p-6 has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-sheen-focus"
>
<h3 className="flex items-center justify-between gap-2 font-semibold">
{/* A stretched link: the whole card is clickable. */}
<a href={plan.href} className="outline-none after:absolute after:inset-0 after:rounded-[inherit]">
{plan.name}
</a>
{plan.tint && <Badge tone="accent">Popular</Badge>}
</h3>
<p className="text-3xl font-semibold tracking-tight">
{plan.price}
<span className="text-sm font-normal text-sheen-fg-muted">/mo</span>
</p>
<p className="text-sm text-sheen-fg-muted">{plan.note}</p>
</TiltCard>
</li>
))}
</ul>
);
}TiltCard props
TiltCardLayer props
Keyboard
Accessibility
- A plain div that does not change reading order. The tilt is transform-only and reads the pointer, not focus.
- It is off for touch (a finger on a card is scrolling) and under reduced motion; TiltCardLayer adds decorative depth.
When to use the 3D tilt card effect
- Use it on a hero tile, a pricing card or a product card that should feel physical under the pointer: it tilts in 3D, and the glare and rim light slide across the glass as it moves.
- Use it for a pricing card or a profile showcase, wrapping the title in TiltCardLayer with a depth so it drifts toward the pointer and appears to float above the surface.
- Tune the motion with maxTilt (0 to 8 degrees), hoverScale and perspective, and set glare={false} when you want the lean without the light.
- Skip it when the card is large, dense or full of controls; a flat glow from SpotlightCard or a calm GlassCard is easier to read, and tilting a form makes it harder to aim.
- Pair it with TiltCardLayer for parallax, Badge for a Featured tag, and Button inside the card, whose tab stops and focus ring stay put while the card tilts.
Frequently asked questions
Related pages
Guides that cover it
19 effects pages in all: browse them on All effects.
By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .