Skip to content
Sign upPro
ConversationReceipt chatMenu

Receipt chat

Chat as a receipt printer. Each answer prints out of a slot above the composer, the paper feeding up as the text streams, then it is cut with a torn edge and settles into the thread.

A dinner bill split prints out of the slot line by line, is cut and settles, then a day plan on a budget prints under it.

Installation

$ pnpm dlx shadcn@latest add https://chatcn.dev/r/receipt-chat.json

Usage

tsx
import { ReceiptChat } from "@/components/ui/chatcn/receipt-chat"

<ReceiptChat
  title="Pocket ledger"
  messages={chat.chatcnMessages}
  status={chat.status}
  onSend={(text) => chat.sendMessage({ text })}
  onStop={chat.stop}
  onRetry={() => chat.regenerate()}
/>

While an answer streams, the paper feeds up by the height of each new line in small motor steps (feed="smooth" eases instead), and the line being printed always sits just above the slot. When the stream ends the foot prints, the blank tail feeds out, and the paper is cut with a torn edge and lifts off with a slight lean, so a thread reads as a stack of real receipts. Scroll up and the feed lets go; send and it returns to the slot.

Markdown tables print as receipt lines with the last column on the right, and a row in bold is a total with a dashed rule above it. A printer prints whole lines: a table row appears once it has fully arrived, so raw pipes never print. The head carries title, the receipt number and the time; the foot carries model, tokens and durationMs from message.metadata when you set them, Stopped early for stopped, then a barcode drawn from the message id. Only text parts print: tool calls and reasoning stay off the paper.

Examples

States

Empty with the end of the roll in the slot, thinking, an error, a finished receipt, one stopped early and a long one.

Props

PropTypeNotes
messagesChatcnMessage[]The thread
status"ready" | "submitted" | "streaming" | "error"Same as AI SDK useChat
errorReactNodeShown with Retry. Say how to fix it
onSend, onStop, onRetry(text) => void, () => void, () => voidWire to your chat
titleReactNodePrinted at the head of every receipt
feed"stepper" | "smooth"How the paper moves. Defaults to stepper
barcodebooleanA barcode from the message id. Defaults to true
renderFooter(message) => ReactNodeExtra lines under the totals
message.metadata{ model?, tokens?, durationMs?, createdAt?, stopped? }The foot
value, defaultValue, onValueChangestringThe input, controlled or not
disabled, autoFocus, localeInput and time formatting
labelsPartial<ReceiptChatLabels>Every string, for translation

Keyboard

KeyAction
EnterSend
Shift EnterNew line
EscapeStop printing

Accessibility

  • The thread is a log region of real text, and each receipt an article named by its number.
  • The torn edges, slot, curl and barcode are decorative and hidden from assistive tech.
  • The finished answer is announced once through a polite live region, never per line.
  • Under forced colors the paper drops its torn edges for a plain border.

Motion

  • The feed moves the thread with additive transform animations, so a fast stream reads as one continuous feed instead of restarting on every line.
  • The cut lifts the receipt 10 px and leans it under 1 degree over 300 ms.
  • Reduced motion keeps every receipt still and flat: text appears, edges still tear.