Performance
Needs attentionFrame rate: 60 fps average, p5 59.9 · Long tasks: 0 tasks, 0 ms total, longest 0 ms · Source gzip 9.2 KB · Runtime 154 KB
Tilt cardMITCardBencho
A card React component by Lorenzo Cabra. Collected unchanged from Bencho under the MIT licence and shown here live.
Quality report
The grade and score come from automated checks run at build or test time. If a check did not run, it is marked Not tested — numbers are never invented.
Frame rate: 60 fps average, p5 59.9 · Long tasks: 0 tasks, 0 ms total, longest 0 ms · Source gzip 9.2 KB · Runtime 154 KB
Issues 0 · Screen reader: Needs attention
No continuous motion
No overflow
Frame rate and long-task figures were measured in headless Chromium with software WebGL. They are only comparable between components on this site, and do not represent real devices.
Not applicable: no visible animation at rest. Hover-triggered animation was not tested.
No axe-core violations.

Checked Nov 15, 2026 · Figures come from an automated script, not from hand-written samples.
Shown at real size.
The copy starts with the licence notice. Keep it when you use the code.
<div id="root"></div>:root{--bg:#f6f4f0;--ink:#17181a;--background:40 20% 96%;--foreground:24 10% 8%;--card:0 0% 100%}html,body{min-height:100%;margin:0;background:var(--bg);color:var(--ink)}html,body{height:100%;overflow:hidden}body{display:grid;place-items:center}#root{display:grid;place-items:center;max-width:100%;max-height:100%;box-sizing:border-box;padding:16px;color:hsl(var(--foreground))}#root.full{width:100%;height:100%;padding:0}@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation-play-state:paused!important;transition-duration:0s!important}}
/*
MIT License
Copyright (c) 2026 Lorenzo Cabra
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---
Not covered by this licence: the Bencho name and the goat mark, and the
photographs shown on bencho.dev (none are included here). Third-party
material keeps its own licence; see THIRD_PARTY.md.
Icon substitution (this copy only): lucide-react (ISC) was replaced with @tabler/icons-react (MIT).
Sample photographs were replaced with Incidental AI assets. The Bencho name and goat mark are not licensed for marketing use.
*/
/* ── Bencho tokens ─────────────────────────────────────────
The custom properties the free blocks read, at the values
bencho.dev draws them with. Light by default; dark under
[data-theme="dark"] on any ancestor, or automatically with
the system setting unless [data-theme="light"] says otherwise.
Map these to your own theme rather than keeping two: a block
only ever reads the names, never the values. */
:root {
--font-ui: "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
--bg: #ffffff;
--board: #ffffff;
--card: #f7f7f6;
--surface: #f7f7f6;
--surface-2: #f1f1f0;
--surface-3: #ecebe7;
--ink: #17181a;
--ink-rgb: 23, 24, 26;
--ink-2: #3c3b37;
--ink-3: #5c5b56;
--ink-4: #6f6e68;
--ink-5: #85847e;
--on-ink: #ffffff;
--on-ink-rgb: 255, 255, 255;
--slab: #17181a;
--on-slab: #ffffff;
--slab-dark: #0e0f11;
--fill-slab: #ffffff;
--fill-on: #17181a;
--fill-on-rgb: 23, 24, 26;
--pane: var(--fill-slab);
--pane-edge: rgba(23, 24, 26, 0.08);
--pane-thumb: rgba(23, 24, 26, 0.07);
--inlay: rgba(255, 255, 255, 0.55);
--inlay-hi: rgba(23, 24, 26, 0.09);
--elev-rgb: 255, 255, 255;
--glass-rgb: 255, 255, 255;
--shadow-rgb: 23, 24, 26;
--wash: 0.06;
--pick: #0d99ff;
--signal: #2231dd;
--focus: #2231dd;
--ok: #15803d;
--ember: #b8431c;
color-scheme: light;
}
[data-theme="dark"] {
--bg: #000000;
--board: #1a1a1a;
--card: #0a0a0a;
--surface: #0f0f0f;
--surface-2: #181818;
--surface-3: #202020;
--ink: #ffffff;
--ink-rgb: 255, 255, 255;
--ink-2: #b4b4b4;
--ink-3: #9a9a9a;
--ink-4: #828282;
--ink-5: #6b6b6b;
--on-ink: #000000;
--on-ink-rgb: 0, 0, 0;
--slab: #1a1a1a;
--on-slab: #ffffff;
--slab-dark: #262626;
--fill-slab: #262626;
--fill-on: #ffffff;
--fill-on-rgb: 255, 255, 255;
--pane-edge: rgba(255, 255, 255, 0.08);
--pane-thumb: rgba(255, 255, 255, 0.07);
--inlay: rgba(255, 255, 255, 0.1);
--inlay-hi: rgba(255, 255, 255, 0.09);
--elev-rgb: 32, 32, 32;
--shadow-rgb: 0, 0, 0;
--wash: 0.09;
--pick: #3aa9ff;
--ok: #34d17a;
color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"]) {
--bg: #000000;
--board: #1a1a1a;
--card: #0a0a0a;
--surface: #0f0f0f;
--surface-2: #181818;
--surface-3: #202020;
--ink: #ffffff;
--ink-rgb: 255, 255, 255;
--ink-2: #b4b4b4;
--ink-3: #9a9a9a;
--ink-4: #828282;
--ink-5: #6b6b6b;
--on-ink: #000000;
--on-ink-rgb: 0, 0, 0;
--slab: #1a1a1a;
--on-slab: #ffffff;
--slab-dark: #262626;
--fill-slab: #262626;
--fill-on: #ffffff;
--fill-on-rgb: 255, 255, 255;
--pane-edge: rgba(255, 255, 255, 0.08);
--pane-thumb: rgba(255, 255, 255, 0.07);
--inlay: rgba(255, 255, 255, 0.1);
--inlay-hi: rgba(255, 255, 255, 0.09);
--elev-rgb: 32, 32, 32;
--shadow-rgb: 0, 0, 0;
--wash: 0.09;
--pick: #3aa9ff;
--ok: #34d17a;
color-scheme: dark;
}
}
/* Tilt.css */
/*
MIT License
Copyright (c) 2026 Lorenzo Cabra
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---
Not covered by this licence: the Bencho name and the goat mark, and the
photographs shown on bencho.dev (none are included here). Third-party
material keeps its own licence; see THIRD_PARTY.md.
Icon substitution (this copy only): lucide-react (ISC) was replaced with @tabler/icons-react (MIT).
Sample photographs were replaced with Incidental AI assets. The Bencho name and goat mark are not licensed for marketing use.
*/
/* ══ Tilt ═══════════════════════════════════════════════════
A picture card that gives under the pointer. Almost nothing
is here: the rotation, both gradients and the shadow are
written per frame from the pointer's position, and a rule
in this file that also had an opinion about any of them
would be a second author. What is left is the things that
are true whatever the pointer is doing. */
.tlt {
position: relative;
/* The frame is what the pointer is measured against and it
is deliberately the ONLY thing in here that never moves.
The perspective lives on it rather than on the card for
the usual reason: on the card itself, `perspective` is
applied per element and the vanishing point rides along
with the rotation instead of staying put in the room. */}
.tlt-card {
position: absolute;
inset: 0;
background-color: var(--surface-2);
background-size: cover;
background-position: center;
/* `cover` and a fixed frame, so the crop is the one
scripts/butterfly.sh already made rather than a second
one on top of it */
overflow: hidden;
/* NO `will-change`. It would hold a composited layer for
every copy of this block on the wall, permanently, to
save one frame on a hover that may never come — the same
bookkeeping CLAUDE.md objects to for permanent rAF. The
browser promotes this on its own once the transform
starts moving. */}
/* ── the dent and the rim ───────────────────────────────────
One element, two gradients, both placed from the pointer —
the dark one under it and the light one at its mirror. It
inherits the corner rather than being told one, so the knob
only has to reach the card. */
.tlt-sheen {
position: absolute;
inset: 0;
border-radius: inherit;
pointer-events: none;}
// bencho source (MIT). npm i motion react · Tailwind CSS v4
// ── blocks/tilt/Tilt.tsx (https://github.com/cabralorenzo/bencho/blob/c65992417427bb09e661674ffa800bef29adef49/blocks/tilt/Tilt.tsx)
/*
MIT License
Copyright (c) 2026 Lorenzo Cabra
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---
Not covered by this licence: the Bencho name and the goat mark, and the
photographs shown on bencho.dev (none are included here). Third-party
material keeps its own licence; see THIRD_PARTY.md.
Icon substitution (this copy only): lucide-react (ISC) was replaced with @tabler/icons-react (MIT).
Sample photographs were replaced with Incidental AI assets. The Bencho name and goat mark are not licensed for marketing use.
*/
import { useEffect, useRef, useState } from "react";
/* ── inlined from lab/spring ──────────────────────── */
/* ── one spring, for everything that settles ───────────────
The maths was already on this bench twice, copied by hand:
Humidity's wheel and Brightness's column both accumulate
velocity toward a target, damp it, and snap when both the
delta and the velocity fall under 0.02. Two copies is a
coincidence; five would be a policy, so it comes out here
before the elastic blocks are written against it.
The two shipped copies are deliberately NOT refactored onto
this. They work, they are tuned, and rewriting the innards
of two live components to prove a point about duplication
is how a good afternoon becomes a bad one. This is the one
new code uses.
Frames, not milliseconds. `dt` is expressed in sixtieths of
a second and the damping is RAISED to it rather than
multiplied by it, so a dropped frame decays the same amount
of energy as the two frames it replaced. Multiplying is the
version that makes a spring behave differently on a busy
page, which is the hardest kind of bug to see.
The loop parks itself the moment the value has settled.
CLAUDE.md is not complimentary about the one permanent
requestAnimationFrame already on this bench and there is no
case for five more. */
/* 0..100 into the two numbers a spring actually has.
50 is what Humidity and Brightness were tuned at, which is
the rule every elastic knob on this bench follows — see
lab/motion. Turn the panel to the middle and nothing has
changed.
Both ends have to be usable, which is what fixes the range:
at 0 it is slow and heavy and still arrives, at 100 it is
quick with a visible overshoot, and nowhere in between does
it ring for longer than it takes to read. */
/* The pair is chosen by DAMPING RATIO and then written back
as stiffness and decay, because the ratio is the thing a
person is actually setting and the two numbers on their own
do not say what they add up to.
zeta = -ln(d) / (2 * sqrt(k))
The first version of this ran 0.06..0.26 stiffness against
0.93..0.74 decay, which reads as a sensible spread and is
not one: it puts zeta between 0.15 and 0.16 across the
WHOLE range, so every setting overshot by about sixty per
cent and the knob only changed how fast it did it. Pull's
return went 130px past its own resting position and lifted
the content off the top of the card.
0 → zeta ~0.85, heavy, arrives without a ring
50 → zeta ~0.41, near where Humidity and Brightness sit
100 → zeta ~0.20, lively, two visible rebounds
Both ends shippable, which is the constraint that fixed the
numbers rather than taste. */
const springOf = (tune: number) => ({
/* stiffness: how hard it is pulled toward the target */
k: 0.08 + (tune / 100) * 0.16,
/* decay, per frame: how much of the velocity survives */
d: 0.62 + (tune / 100) * 0.2,
});
/* Units matter. The snap threshold is absolute, so a caller
works in pixels or in 0..100 — a spring driven over 0..1
would be "settled" before it had visibly moved. */
function useSpring(target: number, tune = 50, instant = false) {
const [at, setAt] = useState(target);
const cur = useRef(target);
const vel = useRef(0);
const raf = useRef(0);
useEffect(() => {
if (instant) {
cur.current = target;
vel.current = 0;
setAt(target);
return;
}
const { k, d } = springOf(tune);
let prev = 0;
const tick = (t: number) => {
const dt = prev ? clamp((t - prev) / 16.67, 0, 2.5) : 1;
prev = t;
vel.current += (target - cur.current) * k * dt;
vel.current *= Math.pow(d, dt);
cur.current += vel.current * dt;
if (Math.abs(target - cur.current) < 0.02 && Math.abs(vel.current) < 0.02) {
cur.current = target;
vel.current = 0;
setAt(target);
raf.current = 0;
return;
}
setAt(cur.current);
raf.current = requestAnimationFrame(tick);
};
raf.current = requestAnimationFrame(tick);
return () => {
cancelAnimationFrame(raf.current);
raf.current = 0;
};
/* `tune` sits here beside `target` for the reason
Brightness spells out: the loop closes over it, so
without it a knob turned mid-flight would do nothing
until something else restarted the effect. Restarting
picks up from the refs, so it continues rather than
snapping. */
}, [target, tune, instant]);
return at;
}
/* Read once, the way the wheel and the pill nav do. A
preference, not a live input. */
const stillness = () =>
typeof window !== "undefined" &&
!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
/* A drawn placeholder: Bencho's photographs are licensed to
the site and do not travel. Point this at your own. */
const BUTTERFLY: string = "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20520%20640%22%20width%3D%22520%22%20height%3D%22640%22%20preserveAspectRatio%3D%22xMidYMid%20slice%22%3E%0A%3Cdefs%3E%3ClinearGradient%20id%3D%22s%22%20x1%3D%220%22%20y1%3D%220%22%20x2%3D%220%22%20y2%3D%221%22%3E%3Cstop%20offset%3D%220%22%20stop-color%3D%22rgb%28231%2C231%2C233%29%22%2F%3E%3Cstop%20offset%3D%221%22%20stop-color%3D%22rgb%28185%2C185%2C187%29%22%2F%3E%3C%2FlinearGradient%3E%3C%2Fdefs%3E%0A%3Crect%20width%3D%22520%22%20height%3D%22640%22%20fill%3D%22url%28%23s%29%22%2F%3E%0A%3Ccircle%20cx%3D%22192%22%20cy%3D%22146%22%20r%3D%2247%22%20fill%3D%22rgb%28246%2C246%2C248%29%22%2F%3E%0A%3Cpath%20d%3D%22M0%2C640%20L0%2C390.5%20L65%2C402.2%20L130%2C375.9%20L195%2C343.8%20L260%2C345.3%20L325%2C378.5%20L390%2C402.8%20L455%2C388.3%20L520%2C352.9%20L520%2C640%20Z%22%20fill%3D%22rgb%28152%2C152%2C154%29%22%2F%3E%0A%3Cpath%20d%3D%22M0%2C640%20L0%2C461.1%20L65%2C440.4%20L130%2C436.3%20L195%2C452.2%20L260%2C475.1%20L325%2C486.4%20L390%2C476.8%20L455%2C454.2%20L520%2C437.0%20L520%2C640%20Z%22%20fill%3D%22rgb%28122%2C122%2C124%29%22%2F%3E%0A%3Cpath%20d%3D%22M0%2C640%20L0%2C532.5%20L65%2C539.0%20L130%2C562.1%20L195%2C568.2%20L260%2C548.3%20L325%2C531.5%20L390%2C542.2%20L455%2C564.9%20L520%2C566.5%20L520%2C640%20Z%22%20fill%3D%22rgb%2891%2C91%2C93%29%22%2F%3E%0A%3C%2Fsvg%3E";
/* ══ Tilt ═════════════════════════════════════════════════
A picture card that gives under the pointer.
IT SINKS, IT DOES NOT LIFT. Every tilt card on the internet
rotates TOWARD the cursor: the corner you are nearest rises
to meet you and the card reads as a slab of glass catching
the light. This one does the opposite — the point you are
over goes AWAY, and the far side comes up. The difference
is one minus sign and it is the whole component: a surface
that rises to your finger is being displayed to you, and a
surface that gives under it is being touched.
Which means the sign is not a detail to get right by
fiddling. Cursor at the top → the top edge has to go back,
which is a POSITIVE rotateX; cursor at the right → the
right edge goes back, which is a positive rotateY. Hence
`rx = -ny` and `ry = +nx`, the negation of the usual pair.
THE ROTATION ALONE IS NOT ENOUGH. A rotation about the
centre is symmetric — the near side down, the far side up
by the same amount — and on its own it reads as a card
pivoting, not as one being pressed. What makes it a press
is that the darkest point tracks the pointer: a depression
catches shadow at its deepest, and the rim opposite catches
light. Those two gradients are doing at least as much of
the work as the transform is, and neither would convince on
its own.
ONE PAIR OF NUMBERS IS THE STATE. Two springs hold where
the pointer is, normalised to -1..1, and the rotation, both
gradients and the shadow are all read off them. Nothing
here has a transition of its own — see the note on Sound
for why that matters, which is the same reason. */
const clamp = (v: number, lo: number, hi: number) => Math.min(hi, Math.max(lo, v));
const mix = (a: number, b: number, t: number) => a + (b - a) * t;
/* Portrait, and the picture is cropped to it by
scripts/butterfly.sh rather than being fitted at runtime —
change one and change the other or the crop moves. */
const W = 260;
const H = 320;
/* ── how deep the room is ──────────────────────────────────
The one number that decides whether this reads as a card
turning or as a poster being sheared. Perspective is the
distance from the viewer to the screen, so a small number
is a face close to the glass: the near corner grows, the
far corner shrinks, and ten degrees looks like thirty.
800 against a 320px card is about two and a half card
heights back — far enough that the foreshortening is a
suggestion rather than a fisheye, close enough that the
corners are visibly different sizes. It is not a knob
because it is not a separate idea from the tilt: both
answer "how 3D", and two sliders for one feeling is how a
panel stops meaning anything. */
const DEPTH = 800;
/* how far the whole card retreats while it is being touched.
Small on purpose — this is the difference between a card
that tips and a card that is pushed, and at anything past
about twenty it stops being a press and becomes a zoom. */
const SINK = 14;
const CORNER = 20;
const TILT = 10;
const SHADE = 60;
export function Tilt({
/* the most either axis turns, in degrees */
tilt = TILT,
corner = CORNER,
/* how dark the dent gets, 0..100 */
shade = SHADE,
}: { tilt?: number; corner?: number; shade?: number } = {}) {
const skin = useRef<HTMLDivElement | null>(null);
const [at, setAt] = useState({ x: 0, y: 0 });
const [on, setOn] = useState(false);
const still = stillness();
/* ── the state, and there is only this ───────────────────
Where the pointer is, as -1..1 on each axis, sprung. The
spring is on the POSITION rather than on the rotation, so
the gradients and the transform can never disagree about
where the finger is — they are three readings of one
number instead of three things being animated towards
the same place.
Sprung rather than tracked one-to-one because a card with
no weight follows the cursor exactly and reads as a
texture pinned to the mouse. The lag is what gives it
mass, and the settle on the way out is the only reason
leaving the card feels like anything at all. */
const sx = useSpring(on ? at.x : 0, 50, still);
const sy = useSpring(on ? at.y : 0, 50, still);
/* one more for how much of any of this applies, so the
shadow and the sheen fade rather than cutting */
const lit = useSpring(on ? 1 : 0, 50, still);
const max = clamp(tilt, 0, 20);
const rx = -sy * max;
const ry = sx * max;
/* the pointer in the card's own terms, as a PERCENTAGE —
the wall and the overlay both draw this block at their
own scale, and a gradient placed in pixels would land
somewhere else in each of them */
const px = ((sx + 1) / 2) * 100;
const py = ((sy + 1) / 2) * 100;
const dark = (clamp(shade, 0, 100) / 100) * 0.55 * lit;
const rim = (clamp(shade, 0, 100) / 100) * 0.34 * lit;
const track = (e: React.PointerEvent) => {
const el = skin.current;
if (!el) return;
/* measured from the FRAME, which never moves. Reading the
card instead would be asking a rotating object where it
is, and near the edges it has already turned away from
the pointer that is asking. */
const r = el.getBoundingClientRect();
setAt({
x: clamp(((e.clientX - r.left) / r.width) * 2 - 1, -1, 1),
y: clamp(((e.clientY - r.top) / r.height) * 2 - 1, -1, 1),
});
setOn(true);
};
return (
<div
className="tlt"
ref={skin}
style={{ width: W, height: H, perspective: DEPTH }}
/* pointer, not mouse: the same handler carries a finger
dragged across the card, so a phone gets the effect
while it is being touched rather than getting nothing
at all. */
onPointerMove={track}
/* ── `out` with a containment test, NOT `leave` ───────
Which is what leave IS — the browser derives it from
exactly this event by asking whether the thing you
moved to is inside the thing you were on — so this is
not a second mechanism, it is the same one written
out. What it buys is the case React would not
synthesise: the rehearsal drives a scripted pointer by
dispatching `pointerout`, and its final beat walks off
the card carrying `relatedTarget: null`. Measured, no
`onPointerLeave` came of it, and every card on the
wall finished its demo still sunk under a cursor that
had gone.
Null counts as outside, which is also the honest
answer for a real pointer leaving the window. */
onPointerOut={(e) => {
const el = skin.current;
const to = e.relatedTarget as Node | null;
if (!el || !to || !el.contains(to)) setOn(false);
}}
/* a touch taken over by a scroll never reports leaving */
onPointerCancel={() => setOn(false)}
>
<div
className="tlt-card"
style={{
borderRadius: clamp(corner, 0, 40),
backgroundImage: `url(${BUTTERFLY})`,
/* translateZ FIRST, so the retreat is measured in
the room's axes rather than in the card's own —
after a rotation, the card's z points somewhere
off to the side and "back" stops meaning back. */
transform: `translateZ(${-SINK * lit}px) rotateX(${rx}deg) rotateY(${ry}deg)`,
/* ── the shadow TIGHTENS ────────────────────────
A thing pressed into a surface has less air under
it, so the gap closes and the shadow draws in.
Growing it on hover is the reflex — it is what a
card that LIFTS would do — and it fights every
other cue here. */
boxShadow: `0 ${mix(20, 9, lit)}px ${mix(44, 24, lit)}px -8px rgba(15, 23, 42, ${mix(
0.22,
0.15,
lit,
)})`,
}}
>
{/* ── the dent, and the rim opposite it ───────────
The shadow pools where the surface is deepest,
which is under the pointer, and the light catches
the far edge that has risen — so the two are
placed at mirrored points and neither is centred
on anything. This is the layer that makes the
transform read as a press. */}
<span
className="tlt-sheen"
aria-hidden="true"
style={{
backgroundImage: `radial-gradient(42% 34% at ${px}% ${py}%, rgba(9, 14, 28, ${dark}) 0%, rgba(9, 14, 28, 0) 100%), radial-gradient(52% 42% at ${
100 - px
}% ${100 - py}%, rgba(255, 255, 255, ${rim}) 0%, rgba(255, 255, 255, 0) 100%)`,
}}
/>
</div>
</div>
);
}Controls · HTML · CSS · JS
Edit the code and tune it with the controls. The preview updates as you type.

This component runs from a bundled build, so its script is read-only here. Edit the HTML and CSS; the full source is in the Code tab.
Edit every component live, tune it with controls, download the full source and copy the advanced prompts.
$49 one-timePlaceholder price
Test mode: no real payment is taken.
Free: preview, copy buttons and the lesson notes.
Generous padding, soft corners and a single accent keep the content in front.
Feature lists, profiles, product tiles and dashboards.
Adjust the padding, the shadow depth and the accent colour.
Add the "Tilt card" component from Bencho (github.com/cabralorenzo/bencho) (MIT) to my React + Tailwind CSS app. Source file: https://github.com/cabralorenzo/bencho/blob/c65992417427bb09e661674ffa800bef29adef49/blocks/tilt/Tilt.tsx. Generous padding, soft corners and a single accent keep the content in front. Use it for: Feature lists, profiles, product tiles and dashboards. Settings to tune: Adjust the padding, the shadow depth and the accent colour. Support light and dark themes and respect prefers-reduced-motion. Keep the MIT licence notice.
A longer prompt with tuning, accessibility and integration steps.