About
File upload as an 8-bit cartridge console with a CRT loading screen. Blow on it if it fails.
Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Cartridge Upload to your project and fits it to your theme.
Code
How Cartridge Upload is used: the demo's code. The component's own source comes with a free account.
Usage.tsx
"use client";
import * as React from "react";
import { CartridgeUpload, type UploadFn } from "@/components/ui/cartridge-upload";
const FONTS = `
@import url('https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600&family=Geist+Mono:wght@400;500;600;700;800;900&family=Press+Start+2P&display=swap');
.cart-demo{font-family:'Geist',ui-sans-serif,system-ui,sans-serif;--font-mono:'Geist Mono'}
.cart-demo .font-mono{font-family:'Geist Mono',ui-monospace,SFMono-Regular,Menlo,monospace}
.cart-demo .font-8bit{font-family:'Press Start 2P',ui-monospace,monospace;font-weight:400}
`;
const SAMPLES: [string, string, number][] = [
["boss-theme.mp3", "audio/mpeg", 4_812_000],
["level-1-map.png", "image/png", 1_204_000],
["save-data.zip", "application/zip", 2_640_000],
];
export default function CartridgeUploadDemo() {
const [sound, setSound] = React.useState(true);
const [failNext, setFailNext] = React.useState(true);
const failRef = React.useRef(failNext);
failRef.current = failNext;
const [log, setLog] = React.useState([] as string[]);
// Simulated upload with real progress events. Fails once when "Fail next" is on.
const upload: UploadFn = (file, report, signal) =>
new Promise((resolve, reject) => {
const shouldFail = failRef.current;
let p = 0;
const id = setInterval(() => {
if (signal.aborted) { clearInterval(id); return reject(new Error("Ejected")); }
p = Math.min(1, p + 0.04 + Math.random() * 0.06);
report(p);
if (shouldFail && p > 0.62) {
clearInterval(id);
setFailNext(false);
return reject(new Error("Checksum mismatch"));
}
if (p >= 1) { clearInterval(id); resolve(); }
}, 110);
});
const addSamples = () => {
const dt = new DataTransfer();
for (const [name, type, size] of SAMPLES) dt.items.add(new File([new Uint8Array(Math.min(size, 2048))], name, { type }));
// hand the files to the component exactly like a drop would
const zone = document.querySelector("[data-cart-demo] [role=button]");
zone?.dispatchEvent(new DragEvent("drop", { bubbles: true, cancelable: true, dataTransfer: dt }));
};
return (
<div data-cart-demo className="cart-demo relative flex min-h-[820px] w-full items-center justify-center overflow-hidden bg-background px-5 py-14">
<style>{FONTS}</style>
<div aria-hidden className="pointer-events-none absolute inset-0 [background-image:radial-gradient(rgb(128_128_128/0.2)_1px,transparent_1px)] [background-size:18px_18px] [mask-image:radial-gradient(ellipse_at_center,black_15%,transparent_72%)]" />
<div aria-hidden className="pointer-events-none absolute left-1/2 top-[38%] h-72 w-[44rem] -translate-x-1/2 rounded-full bg-indigo-500/[0.08] blur-3xl" />
<div className="relative w-full max-w-[720px]">
<div className="mb-6 flex flex-wrap items-start justify-between gap-4 px-1">
<div>
<p className="font-mono text-[10.5px] uppercase tracking-[0.24em] text-muted-foreground">File upload · cart-os 1.0</p>
<h2 className="font-8bit mt-3 text-[22px] leading-[1.35] text-foreground">Insert cartridge.</h2>
<p className="mt-3 max-w-md text-[14px] leading-relaxed text-muted-foreground">
Drop any file and it becomes a cartridge. Upload progress plays on the CRT. If it fails, blow on it.
</p>
</div>
<div className="flex flex-col items-end gap-2">
<button
type="button"
onClick={() => setSound((s) => !s)}
aria-pressed={sound}
className="inline-flex items-center gap-1.5 rounded-md px-2 py-1 font-mono text-[10.5px] uppercase tracking-[0.14em] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"
>
<svg viewBox="0 0 16 16" className="size-3" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" aria-hidden>
<path d="M2.5 6h2l3-2.5v9L4.5 10h-2z" />
{sound ? <path d="M10.5 5.5a3.5 3.5 0 0 1 0 5M12.5 3.5a6.3 6.3 0 0 1 0 9" /> : <path d="m10.5 6 4 4m0-4-4 4" />}
</svg>
{sound ? "Sound" : "Muted"}
</button>
<label className="inline-flex cursor-pointer items-center gap-2 font-mono text-[10.5px] uppercase tracking-[0.14em] text-muted-foreground">
<input type="checkbox" checked={failNext} onChange={(e) => setFailNext(e.target.checked)} className="accent-red-500" />
Fail next upload
</label>
</div>
</div>
<CartridgeUpload
onUpload={upload}
sound={sound}
maxSize={50 * 1024 * 1024}
onComplete={(f) => setLog((l) => [`${f.name} uploaded`, ...l].slice(0, 3))}
/>
<div className="mt-4 flex flex-wrap items-center justify-between gap-3 px-1">
<button
type="button"
onClick={addSamples}
className="h-9 rounded-lg bg-foreground px-3.5 text-[13px] font-medium text-background transition-opacity hover:opacity-90"
>
Load sample carts
</button>
<span className="font-mono text-[10.5px] uppercase tracking-[0.12em] text-muted-foreground">
{log[0] ?? "Enter: choose · B: blow · Esc: eject"}
</span>
</div>
</div>
</div>
);
}








