Components

Receipt

Thermal till paper: pinked (or perforated, or torn) at both ends, printed in the typewriter font, its lines a description list, its total circled in red felt tip by whoever checked it, ending in a barcode made from the number under it.

Install

terminal
npx shadcn@latest add @wobko/receipt

First time here? Add the registry to components.json first. How to install

Examples

A receipt

Pinked at both ends, typed, the lines a description list. The total is bigger; nothing else is.

Circled, barcoded, clipped

The total circled in red felt tip, a barcode whose bars come from the number under it, and a paper clip to keep it with the invoice.

Four ways to cut it

`ends` is the cut of both ends: the tear bar's sawtooth, a perforation, a hand tear, or a plain guillotine.

An order summary

A real checkout: quantities you can change, a total that follows, and the barcode of the order number. The receipt is ordinary DOM; only the ink is drawn.

API reference

Receipt

A Paper on the `receipt` stock, a centered 18 rem column with the type font. It takes every Paper prop except `stock`, `rules` and `edge`.

PropTypeDefaultDescription
ends"zig" | "perf" | "torn" | "cut" | "deckle" | "crimp" | "scallop""zig"The cut of both ends: the tear bar's sawtooth, a perforation, torn, or plain.

ReceiptLine

One item: a `div` holding a `dt` (the item; a long name wraps onto a second line, as a thermal printer would, and never hides behind an ellipsis) and a `dd` (the price, tabular figures, aligned to the end, on the first line).

PropTypeDefaultDescription
qtynumber-How many, printed before the item as `2 x`.
priceReactNode-The price.

ReceiptTotal

A `dl` of its own (label and amount, larger and bold).

PropTypeDefaultDescription
labelReactNode"TOTAL"The label.
circledboolean | "red" | "blue" | "ink"falseCircle the amount in felt tip. `true` is red. Calm density draws a hairline loop.
seedstring | number-Pins the hand of the loop.

ReceiptBarcode

Bars from `value` in a `figure` with the number printed under them. The same number always prints the same bars, on the server and in the browser.

PropTypeDefaultDescription
valuestring-The number.
heightnumber44Bar height in px.

Accessibility

  • A receipt is a plain `div` by default, and a name on a `div` is ignored by screen readers: pass `as="article"` (it is a self-contained document) together with `aria-label`, as the examples do.
  • The lines are a real description list, so a screen reader hears each item with its price. The total is a list of its own, with the same structure.
  • The barcode is `role="img"` named `Barcode <number>`; the number is also printed as text. The circle round the total, the pinked ends, tape and clips are aria-hidden decoration: the amount is text either way.
  • Ink on the receipt stock is 14:1; the footer is 8:1. The type font is set at 13 px on a 20 px line. Windows high contrast replaces the drawn ends with an outline.

Source

The files the CLI copies into your project.

Loading the source