Mariia

Receipt Checkout

Component 23

About

A checkout that feeds an itemized receipt through a chrome printer. A text-only PAID stamp marks a successful payment. Includes order totals, retry handling, and a replayable paper animation.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Receipt Checkout to your project and fits it to your theme.

Code

How Receipt Checkout is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";
import { useLayoutEffect, useRef } from 'react';
import { ReceiptCheckout } from '@/components/ui/receipt-checkout';
const items = [
  { id: 'hoops', name: 'Everyday hoops', description: 'GOLD / SMALL', quantity: 1, price: 4800 },
  { id: 'ring', name: 'Solstice ring', description: 'GOLD / SIZE 7', quantity: 1, price: 3600 },
  { id: 'pouch', name: 'Jewellery pouch', description: 'NATURAL COTTON', quantity: 1, price: 1200 },
];
export default function ReceiptDemo() {
  const frame = useRef<HTMLElement>(null);
  const receipt = useRef<HTMLDivElement>(null);

  useLayoutEffect(() => {
    const stage = frame.current!;
    const content = receipt.current!;
    function fit() {
      const padding = parseFloat(getComputedStyle(stage).paddingTop);
      const available = stage.clientHeight - 2 * padding;
      const scale = Math.min(1, available / Math.max(1, content.offsetHeight));
      content.style.transform = `scale(${Math.max(0, scale)})`;
    }
    fit();
    const observer = new ResizeObserver(fit);
    observer.observe(stage);
    observer.observe(content);
    return () => observer.disconnect();
  }, []);

  return (
    <main ref={frame} className="receipt-demo">
      <style>{`
        html, body, #root { margin: 0; }
        .receipt-demo {
          position: fixed;
          inset: 0;
          display: grid;
          grid-template: minmax(0, 1fr) / minmax(0, 1fr);
          place-items: center;
          padding: clamp(12px, 8vh, 72px) 12px;
          box-sizing: border-box;
          overflow: hidden;
          background: #271635;
        }
        .receipt-demo-wrap { width: min(100%, 480px); }
        .receipt-demo .rt-reprint { color: #fff4ed; }
        @media (max-width: 480px) {
          .receipt-demo { padding-block: 12px; }
        }
      `}</style>
      <div ref={receipt} className="receipt-demo-wrap">
        <ReceiptCheckout items={items} storeName="BASKET" orderNumber="001284"
          successMessage="Demo payment · No charge"
          onPay={() => new Promise(resolve => setTimeout(resolve, 1100))}
        />
      </div>
    </main>
  );
}

More by Mariia

View all
  • Soft Keys

    Soft Keys

    8
  • Editorial Calendar

    Editorial Calendar

    4