How it works
A card with a slot near its bottom edge and, under it, a window that always reserves the receipt's height. The window's top edge is the middle of the slot: clip-path cuts the paper there but lets its shadow out at the sides and bottom, and a soft dark band at the top sells the slot. While printing, the paper slides from translateY(-100%) to 0 in five feeds with short stops (one keyframe animation), and the status light beside the slot blinks. The total is always the real amount: a figure that changes while it prints would read as a wrong charge. The bottom edge is torn into teeth by a CSS mask; the drop-shadow sits on the unmasked wrapper so it follows the teeth. The barcode row is drawn from the order code.
Use it for
- The moment after a payment, a top-up or a booking, when a summary of what was paid is the best confirmation.
- Point-of-sale, café, shop and ticket flows where a receipt is what people expect.
- Order confirmations that should feel tangible rather than a plain green banner.
Look elsewhere when
- Long invoices with many lines: show a full invoice page or a downloadable document.
- Confirmations of actions that involve no money or items: a success check is enough.
Usage
import { useState } from 'react'
import { ReceiptPrint } from './ReceiptPrint.jsx'
const items = [
{ label: 'Flat white', qty: 2, amount: 9 },
{ label: 'Almond croissant', amount: 5.4 },
{ label: 'Sparkling water', amount: 4 },
]
export function Checkout() {
const [status, setStatus] = useState('idle')
const pay = async () => {
await fetch('/api/pay', { method: 'POST' })
setStatus('printing')
}
return (
<ReceiptPrint
status={status}
onPrinted={() => setStatus('printed')}
merchant="Corner Café"
code="A-2417"
items={items}
meta="Nov 25 · 09:41 · Card ·· 4821"
>
<div className="pay-row">
<strong>Corner Café</strong>
<button onClick={pay} disabled={status !== 'idle'}>Pay $18.40</button>
</div>
</ReceiptPrint>
)
}Props
| Prop | Type | Default | What it does |
|---|---|---|---|
status | 'idle' | 'printing' | 'printed' | 'idle' | idle: no paper. printing: the receipt feeds out, then onPrinted is called. printed: the receipt is shown at rest without motion (for one that already exists when the page loads). |
children | ReactNode | — | Content of the card above the slot: the merchant, the amount, a pay button. Inside it, var(--ds-receipt-card) and var(--ds-receipt-on-card) give the card colour and the ink on it, so a button can be the card's inverse in both themes. |
merchant / mark / code | string / ReactNode / string | — | Receipt heading, the small square mark beside it (defaults to the merchant's initial) and an order code; the code also seeds the barcode row. |
items | { label, amount, qty? }[] | — | Receipt lines. qty above 1 is shown as “×2” after the label. |
total | number | sum of items | The total, always shown as the final amount. |
format | (n) => string | n => `$${n.toFixed(2)}` | Formats every amount, including the total. |
meta | ReactNode | — | A small line under the total, such as date, time and card ending. |
tone | 'ink' | 'surface' | 'ink' | The card: ink (a raised dark surface in the dark theme) or the surface colour with the card shadow. The paper stays light with dark print in both themes. |
duration | number | 1800 | Length of the whole print in ms, five feeds with short stops. |
onPrinted | () => void | — | Called when the receipt is fully out (at once with reduced motion). Set status to 'printed' here. |
labels | object | — | Replaces built-in text: receipt, total, printing, printed. Shallow-merged over the English defaults. |
...rest | HTMLAttributes | — | Other attributes go to the root <div>. |
Accessibility
- The receipt is a <section> named by its heading, with the lines as a real list; while idle it is hidden from assistive tech.
- “Printing receipt…” and “Receipt ready” are announced through a polite live region; replace them with labels.
- The status light is not the only signal: the receipt itself and the announcement carry the state.
- Reduced motion shows the receipt at once, without the feed or the blinking light, and calls onPrinted immediately.
Motion
Feed: 1800ms by default, five moves of about 22% each with 6% stops, each move cubic-bezier(0.35, 0, 0.25, 1); the light blinks every 360ms while printing and then stays lit with a soft halo.
Add it to your project
Pro members copy a prompt and their coding agent installs the source, the same way as the free components.
ReceiptPrint.jsxreceipt-print.csstokens.cssREADME.md
Both files install together. The stylesheet reads the design tokens in tokens.css and carries fallbacks, so it also works alone.



