SwipeUI

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-printer
Variant
Preset
Material
Scheme
Feel
Interactive web demo. Native materials, gestures and system presentation differ on device.

When 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: printSpeed is slow, normal, fast, or points of paper per second; it sets the pace of both feed and lines.
  • Payment: signable adds Sign; the signature is drawn over the last rows and comes back through onSignature.

Rows

TypeFieldsDraws
headerleft, rightA small line with text at both ends
titletextA bold centred heading
captiontextSmall centred text
paragraphtextBody text
linelabel, valueA label and its value
totallabel, valueA bold label and value
rulestyle: dashed, dotted, solid or doubleA divider
barcodevalueA Code 128 barcode with its text
spacersize: sm, md or lgBlank paper
footertextSmall centred closing text
customrender, labelAnything; label is what screen readers hear

Receipt printer settings

PropDoesDefault
rowsThe receipt, top to bottom—
printStylefeed, lines or nonefeed
printOnMountPrint as soon as it appearstrue
printSpeedslow, normal, fast, or points per secondnormal
tearablePull the paper to tear it offtrue
tearThresholdHow far to pull, in points96
signableThe receipt takes a signaturefalse
signing, onSigningChangeWhether the signature is taking inkfalse
edgezigzag, scallop or straightzigzag
actionsfalse, or { save, tear, sign }All that apply
captureAdapterMakes the image for Save and capture()—
onSaveThe image's URI or data—
onTearThe paper was torn off—
tearSoundPlays as the paper rips; call your own player—
tearSoundAtHow far into a pull the sound starts, 0 to 1 of tearThreshold; 1 waits for the tear0.2
onPrintEndThe receipt finished printing—
onSignatureThe signature's strokes changed—
hapticsA switch, or { line, tear, sign }true
palette{ paper, ink, faint, signature }Cream paper
messagesBuilt-in stringsEnglish
motionLocal motion feelApp feel
slotClassNameClasses for the printer slot—

Ref

MethodDoes
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, drag and overlay motion roles, so it follows your app's feel. Pass motion to 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 onSupported
Expo SDK 57Yes
Expo SDK 58Yes
React Native CLI (with Expo modules)Yes
Expo GoYes
iOSYes
AndroidYes

This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.

Related items