Tilt Flip Polaroid
A Polaroid print that tilts away from the pointer with a damped 3D tilt, then flips around its Y axis to reveal a handwritten note. The hit area stays flat while the card moves, so the pointer never chases a rotated target.
Installation#
pnpm dlx shadcn@latest add @davinciui/tilt-flip-polaroidUsage#
API Reference#
| Prop | Type | Default |
|---|---|---|
imagePhoto shown inside the 12px inset. The 372 x 367 box is reserved with a neutral placeholder while the image loads. | { src: string; alt: string } | — |
dateCaption centred in the 64px strip below the photo, rendered in Caveat. | string | "11/07/24" |
backTextHandwritten note on the back face. Each newline is preserved; the block is centred with 45px horizontal padding. | string | november, late afternoon. … |
flippedControlled flipped state. When supplied, internal clicks call onFlippedChange without mutating internal state. | boolean | — |
defaultFlippedInitial flipped state for uncontrolled usage. | boolean | false |
onFlippedChangeFires for clicks, taps, Space, and Enter in both controlled and uncontrolled modes. | (flipped: boolean) => void | — |
maxTiltMaximum rotation in degrees per axis. The pointer offset is normalized by half the card size and clamped to ±1. | number | 15 |
perspectivePerspective distance on the static hit-area wrapper. No translation or in-plane rotation is applied to the card. | number | 1000 |
tiltEnabledTurns pointer tilt off while keeping click, tap, and keyboard flipping. Tilt is always off for coarse pointers and reduced motion. | boolean | true |
selectableBackAllows selecting the back text. Selection is disabled on the card by default. | boolean | false |
widthCard width in CSS pixels. | number | 396 |
heightCard height in CSS pixels. | number | 443 |
classNameAdditional classes on the hit-area wrapper. The card visuals are driven by --tfp-* CSS variables. | string | — |
styleOptional inline overrides, including --tfp-card, --tfp-ink, --tfp-inset, --tfp-caption, --tfp-radius, and --tfp-shadow. | React.CSSProperties | — |
Accessibility#
The static hit area is a role='button' with tabIndex 0, aria-pressed reflecting the flipped state, and a label built from the photo alt text. Space and Enter flip, a focus-visible ring is shown, and the face that is not visible is aria-hidden. Tilt is pointer-only and disabled for coarse pointers; touch and keyboard still flip.
Motion#
Pointer tilt retargets rotateX and rotateY motion values through a stiffness 100 / damping 18 spring, and the flip retargets a stiffness 400 / damping 40 spring so rapid clicks reverse without a jump. Reduced motion disables tilt and replaces the 180deg flip with a 150ms opacity crossfade.
View source
Keep in mind
Need a custom component?
I build bespoke UI components & websites tailored to your brand.

