Receipt printer
A till receipt built from row data that feeds out of a printer slot, tears off with a drag, takes a signature and saves as an image through your own capture adapter.
npx @swipeui/cli add receipt-printerWhen to use it
- A run, order or payment summary people enjoy watching print and want to share.
- A bill that needs a signature, or a paper-style receipt on its own with ReceiptPaper.
When not to use it
- A long itemised order people need to scroll and edit: use a list.
- A scannable QR code: the barcode row is Code 128 only.
Installation
Installs with a Pro licence
Everything on this page is public except the source. Founder pre-sale opens around 5 January 2027.
Usage
import { ReceiptPrinter } from '@/components/swipeui/special/receipt-printer';
import type { ReceiptRow } from '@/components/swipeui/special/receipt-printer';
const rows: ReceiptRow[] = [
{ type: 'title', text: 'MORNING RUN' },
{ type: 'rule' },
{ type: 'line', label: 'Distance', value: '5.42 km' },
{ type: 'line', label: 'Time', value: '28:14' },
{ type: 'total', label: 'Best 1 km', value: '4:51' },
{ type: 'barcode', value: 'RUN-1111-0542' },
];
<ReceiptPrinter rows={rows} onTear={() => router.back()} />;The receipt is data. Values are strings you have already formatted, so money, units and dates follow your own locale rules.
Examples
- Run summary:
printStyle="lines"prints row by row, with a tick per row. - Shop: the same print with
edge="scallop". - Speed:
printSpeedisslow,normal,fast, or points of paper per second; it sets the pace of bothfeedandlines. - Payment:
signableadds Sign; the signature is drawn over the last rows and comes back throughonSignature.
Rows
| Type | Fields | Draws |
|---|---|---|
| header | left, right | A small line with text at both ends |
| title | text | A bold centred heading |
| caption | text | Small centred text |
| paragraph | text | Body text |
| line | label, value | A label and its value |
| total | label, value | A bold label and value |
| rule | style: dashed, dotted, solid or double | A divider |
| barcode | value | A Code 128 barcode with its text |
| spacer | size: sm, md or lg | Blank paper |
| footer | text | Small centred closing text |
| custom | render, label | Anything; label is what screen readers hear |
Receipt printer settings
| Prop | Does | Default |
|---|---|---|
| rows | The receipt, top to bottom | — |
| printStyle | feed, lines or none | feed |
| printOnMount | Print as soon as it appears | true |
| printSpeed | slow, normal, fast, or points per second | normal |
| tearable | Pull the paper to tear it off | true |
| tearThreshold | How far to pull, in points | 96 |
| signable | The receipt takes a signature | false |
| signing, onSigningChange | Whether the signature is taking ink | false |
| edge | zigzag, scallop or straight | zigzag |
| actions | false, or { save, tear, sign } | All that apply |
| captureAdapter | Makes the image for Save and capture() | — |
| onSave | The image's URI or data | — |
| onTear | The paper was torn off | — |
| tearSound | Plays as the paper rips; call your own player | — |
| tearSoundAt | How far into a pull the sound starts, 0 to 1 of tearThreshold; 1 waits for the tear | 0.2 |
| onPrintEnd | The receipt finished printing | — |
| onSignature | The signature's strokes changed | — |
| haptics | A switch, or { line, tear, sign } | true |
| palette | { paper, ink, faint, signature } | Cream paper |
| messages | Built-in strings | English |
| motion | Local motion feel | App feel |
| slotClassName | Classes for the printer slot | — |
Ref
| Method | Does |
|---|---|
| print() | Prints the receipt again |
| tear() | Rips the paper off at the slot |
| reset() | Puts the printed receipt back and wipes the signature |
| capture(options) | An image through captureAdapter; rejects without one |
Composition and behavior
Pull the paper down, sideways or diagonally and a crack opens at the slot, from the side the paper is leaving, while the paper hangs from its other corner. Past tearThreshold it rips, swings and falls away, leaving a torn stub in the slot; released early, it closes again. Tear off, tear() and the Tear off accessibility action do the same. Leave room under the printer for the paper to fall, and don't clip it inside a card.
Save appears only when you pass a captureAdapter, because the printer adds no image dependency:
import { captureRef } from 'react-native-view-shot';
<ReceiptPrinter
rows={rows}
captureAdapter={(target, options) => captureRef(target, options)}
onSave={(uri) => share(uri)}
/>;To add a tearing sound, pass tearSound. The printer ships no audio dependency. Give it a player and the sound follows the hand: it plays while the paper tears, holds when the pull stops, and plays out once the paper is off:
import { useAudioPlayer } from 'expo-audio';
const rip = useAudioPlayer(require('./tear.mp3'));
<ReceiptPrinter
rows={rows}
tearSound={{
play: () => {
rip.loop = true;
rip.play();
},
pause: () => rip.pause(),
reset: () => rip.seekTo(0),
finish: () => {
rip.loop = false;
rip.play();
},
}}
/>;A plain function (tearSound={() => rip.play()}) plays once instead, at tearSoundAt.
For a receipt with no printer, use the paper on its own: <ReceiptPaper rows={rows} edge="scallop" />.
Paper stays paper-coloured in dark mode; change it with palette. The slot and the buttons follow the theme. The barcode is Code 128 (code set B: letters, digits and punctuation); other characters are dropped.
Screen readers hear the paper as one summary in order, such as "Receipt. Distance, 5.42 km. Best 1 km, 4:51." Rules and the torn edge are skipped. With Reduce Motion the receipt appears printed and a torn receipt disappears without falling. The public demonstration is written separately for the browser, and its barcode is decorative.
Behavior and gestures
- The receipt feeds out of the slot when the printer appears, smoothly or row by row with a tick per row, at a slow, normal or fast speed.
- Pull the paper down, sideways or diagonally: a crack opens at the slot and the paper hangs from one corner. Past the threshold it tears, swings and falls away, leaving a stub in the slot. Released early, it closes. Tear off does the same.
- Sign puts a signature line over the last rows; Done keeps the ink and Clear wipes it.
- Save makes an image of the paper through your capture adapter.
Accessibility
- The paper is one text element that reads the receipt in order, such as Receipt. Distance, 5.42 km. Total, 7.80.
- Rules, the slot and the torn edge are hidden from screen readers; a barcode is read as Barcode and its text.
- Tear off and Sign are buttons and accessibility actions on the paper; tearing and saving are announced once.
Motion
- Uses the
layout,dragandoverlaymotion roles, so it follows your app's feel. Passmotionto tune this one instance. - The paper feeds at a steady rate set by printSpeed; each row of a line-by-line print is its own short spring on the layout role.
- The crack follows the finger and closes on the drag role; the torn paper swings, falls and fades on the overlay role's exit.
- Reduce Motion: the receipt appears printed at once and a torn receipt disappears without falling; haptics stay.
Performance
- Rows are plain views; the print, the drag and the fall each move one transform on the UI thread.
- Barcode bars are snapped to whole physical pixels.
Notes for AI
- rows is data: build it from your order or activity. Values are already formatted strings, so format money and units yourself.
- Save and capture() need captureAdapter, for example (target, options) => captureRef(target, options) with react-native-view-shot.
- Wrap the screen in GestureHandlerRootView and keep the printer on a screen that does not scroll under the paper.
Compatibility
| Runs on | Supported |
|---|---|
| Expo SDK 57 | Yes |
| Expo SDK 58 | Yes |
| React Native CLI (with Expo modules) | Yes |
| Expo Go | Yes |
| iOS | Yes |
| Android | Yes |
This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.