A gift card as an object: foil that follows the hand, a code hidden in a sleeve until it is opened, then copyable; amount and dates formatted by locale.
Press mePress me
Torrefazione Alba
Gift · Order 2041
Ines sent you €50
Open the card to see your code. It works for beans, gear and the bar.
Happy birthday! For the long mornings with the window open.
Try the Huila first, then tell me.
gift-card · , lively
gift-card-demo.tsx
When to use
Use it where a gift card is the thing itself: it formats the money, keeps the code out of the page until the card is opened, then offers a copy button.
When not to use
For a plain discount code inside a list use Copy Button next to the text. It is a single card, not a list of vouchers.
Use it where a gift card is the thing itself: the page a recipient lands on from the email, the
account wallet that holds received cards, and the checkout step where the buyer sets the amount
and the message and sees the card change live. It formats the money, hides the code until the card
is opened and hands the code over with a copy button. For a plain discount code inside a list, a
copy-button next to the text is enough.
import { GiftCard } from "@/components/ui/gift-card"export function GiftPage({ gift }: { gift: Gift }) { return ( <GiftCard amount={gift.amount} currency="EUR" locale="en-GB" code={gift.code} from={gift.sender} to={gift.recipient} message={gift.message} expiresAt={gift.expiresOn} onReveal={() => track("gift_opened", { id: gift.id })} /> )}
Heavy card stock in your card token with one band of foil in primary. The foil is the light: as
the card tilts toward the hand, a narrow highlight crosses the band, the upper edge catches a rim
light and a soft sheen drifts the other way; the shadow under the card is tinted with primary. The
amount is blind-embossed, large and tabular. Press "Open your gift": the card pulls back 4 px into
its sleeve, the sleeve is drawn down off it on the spring, overshoots and rests while the foil
highlight sweeps once; the page below makes room once, on the calm spring. The
code is then real, selectable text with a copy button.
The card never moves on its own: it tilts only while a mouse is over it or a finger is on it, and
the foil sweeps only on the reveal.
amount is in currency units (50 is €50) and is formatted with Intl.NumberFormat from locale
and currency: whole amounts print without cents. Change amount and the digits roll (a
number-ticker) while the card gives one small nod. expiresAt takes a Date or "YYYY-MM-DD"
and prints as a calendar day in UTC, so the server and the client agree. Every string, including
the reveal button and the announcement, is in labels.
Long names wrap and long messages are clamped to three lines in a box reserved for them, with a
"Read all" button when the clamp actually cuts the text: the card never changes size.
Without code there is nothing to open: that is the buyer's live preview. With code, it is not in
the page at all until the card is opened, so it cannot be read from the DOM or by a screen reader
early. revealed is controlled (store it per recipient) or uncontrolled with defaultRevealed.
onReveal runs when the person opens the card, onCopy(code) after a copy.
foil (default): a paper sleeve with a ball-shaped thumb cut; drawn down, it frees the card.
emboss: a tonal card with no foil, a debossed frame and a sheen; it flips on its long axis and
the code is on the back, under a matte strip.
band: a paper belly band printed with the names and a seal ball holds the card; on reveal it
slips off sideways round the card's edge and shows the code.
Set the character with temperament (calm, lively, playful) or MotionKitProvider: it
changes how far the card tilts and how much it overshoots. calm keeps the 4 px pull and the slide,
without overshoot. tilt={false} switches the hand-driven tilt off.
The page a recipient opens from the email of an invented roaster: "Ines sent you €50", her
two-line message, the card in its sleeve and the expiry in the shop's own words.
Press mePress me
Torrefazione Alba
Gift · Order 2041
Ines sent you €50
Open the card to see your code. It works for beans, gear and the bar.
The buyer picks €25, €50 or €100 with a segmented-control, types the recipient and the message,
and the band card beside the form follows: the digits roll and the band prints the new name.
A received card in a bookshop account, in Italian (locale="it-IT", labels translated), with the
emboss preset: "Gira la carta" flips it and the code is on the back.
The card is a group named by its amount ("€50 gift card"). The amount, the names, the message
and the expiry (a <time>) are real text in foreground or muted-foreground on card stock or
paper: AA in both themes. No text sits on the foil.
The reveal is a real button, 44 px tall. Before it is pressed the code is not rendered. After,
focus moves to the copy button and a polite live region says "Gift card opened. The code is on the
card."
The foil, the sheen, the sleeve, the belly band and the frame are aria-hidden and take no
pointer, so nothing decorative blocks a click.
Hover has two alternatives: a finger on the card tilts it (horizontal moves; vertical moves still
scroll the page), and keyboard focus on a control inside the card leans it to its best angle so
the foil catches the light.
No tilt, nod, pull or sweep. The foil rests at its best angle with the highlight just above the
middle of the band. The sleeve, the flip or the band change at once and the code fades in.
Motion only: transform and opacity on a few layers, CSS gradients for the foil and the sheen,
no canvas. Springs run only while the hand moves or the card opens; nothing loops, so there is
nothing to pause off screen.
Space is reserved for every state: the sleeve's height is part of the card's box from the first
frame, the message box keeps three lines.