A pay button whose pill unrolls into a folded receipt with line items and follow-ups (Download PDF, Email receipt); on failure it opens halfway with the reason.
Press mePress me
Payment method
Billing details
Order summary
Team plan · monthly
€49.00
5 seats × €9.80
incl. VAT
Due today
€49.00
Renews on Dec 2. Cancel anytime from Billing.
receipt-fold · , lively
receipt-fold-demo.tsx
When to use
Use it for the one button that takes money, when the result is a receipt to show. Return the receipt from onPay, or reject with a reason that prints on the half-open receipt.
When not to use
For actions that return no document (save, invite) use Action Button with a toast.
Use Receipt Fold for the one button that takes money: a checkout, an invoice, a credits top-up. Pressing sinks the pill and shows the lip of a receipt under it; while the payment runs the pill stays down. On success the pill's bottom edge unrolls into a receipt tile in two 32 px folds with the amount, the method and the receipt number. On failure only the first fold opens, in destructive, with the reason, and it snaps back into the pill on the next try. The length tells the outcome before the text is read. For actions that do not return a document (save, invite), use a regular button with a toast.
With actions, a successful receipt ends in one more fold with up to two follow-ups, such as "Download PDF" and "Email receipt". They are real buttons that receive the printed receipt; when onSelect returns a promise the button shows as busy, then swaps to its doneLabel with a check ("Sent to billing"), so the confirmation lands where the person looked.
placement decides where the receipt lives. inline puts it in the flow: the card grows with the settled receipt and the content below moves once, smoothly (the overshoot and the error wobble stay overlaid, so nothing jitters). The default overlay hangs it over the content below without taking layout space: leave about 80 px free under the button (110 px with the invoice preset, 36 px more with actions) and make sure no ancestor clips it with overflow: hidden.
onPay returns a promise. Resolve it with { title, aside, lines }: title and aside print on the first fold, each entry of lines on the next one. A line is a string, or a line item { label, value } with the amount aligned right in tabular figures. Reject it with an Error, { reason } or a string: that reason prints on the half receipt (errorFallback when there is none). pendingLabel, paidLabel and retryLabel name the button in each status; onStatusChange reports idle, pending, success and error.
Presets: checkout (default, two folds, pays once), invoice (three folds, pays once) and top-up (two folds; pressing again folds the last receipt back in and pays again). folds and repeat override the preset. Change resetKey to fold the receipt back in and return to the resting label, for example when a new order starts. buttonProps is spread on the button; its handlers run before the component's.
Set the character for the whole app with MotionKitProvider, or per instance with temperament (calm, lively, playful). It changes motion intensity only, never the drawing.
The default demo: the Billing settings of a workspace upgrading to the Team plan, with placement="inline", the line items (plan and VAT) and the two follow-ups. On first view it pays with the Visa; pick the expired Mastercard and pay again: the receipt opens only halfway with the reason.
An accounts-payable panel with the invoice preset: the button is disabled until the invoice is approved, the receipt repeats the invoice lines with their amounts and ends with one follow-up, "Attach to bill".
The control is a native button. While the payment runs it has aria-busy; after a one-time success it is aria-disabled and ignores presses.
The receipt is real, selectable text, linked to the button with aria-describedby. A polite live region announces the outcome ("Paid €49.00, Visa 4242, Receipt #A-1042") or the reason.
The receipt's outline, shadow and creases are an aria-hidden SVG.
Follow-up actions are native buttons after the pay button in tab order. They are inert while the receipt is folding back in, are aria-busy while their promise runs, and the doneLabel is announced. They are not part of the receipt text the pay button is described by.
The pill uses primary with a hairline rim and a tinted shadow. The error receipt is a light destructive tint whose text caps the destructive lightness (light) or raises it (dark), so it stays at least 4.5:1 in both themes. Focus shows a 2 px outline offset from the pill.
No sink, lip, folds, overshoot or wobble: the receipt fades in already open (half open on an error) and fades out on retry or reset. Labels and announcements are the same.