Bubble wrap
Press to pop, or drag across to pop a whole row.
Installation
Run the CLI
Run
pnpm dlx asta-ui@latest initonce, then this. The file lands incomponents/astabyte/and the colour tokens go into your CSS.$ pnpm dlx asta-ui@latest add bubble-wrapOr install the package
Don’t want the file? Import from
asta-ui/bubble-wrapand update withpnpm update asta-ui. Add the stylesheet once. More.$ pnpm add asta-uiimport { BubbleWrap } from "asta-ui/bubble-wrap";Or copy it by hand
Copy this file. Keep the paths, or fix the
@/imports. Then add the tokens fromglobals.css."use client"; import { useState } from "react"; const COLS = 7; const ROWS = 4; /** Pop every bubble — press, or drag across to pop a whole row. */ export default function BubbleWrap() { const [popped, setPopped] = useState<boolean[]>(() => Array(COLS * ROWS).fill(false)); const left = popped.filter((p) => !p).length; const pop = (i: number) => { if (popped[i]) return; navigator.vibrate?.(6); setPopped((p) => p.map((v, k) => (k === i ? true : v))); }; const fromPoint = (e: React.PointerEvent) => { const el = document.elementFromPoint(e.clientX, e.clientY) as HTMLElement | null; const i = el?.dataset.bubble; if (i !== undefined) pop(Number(i)); }; return ( <div className="flex h-full w-full flex-col items-center justify-center gap-4 p-4"> <div onPointerDown={(e) => { e.currentTarget.releasePointerCapture?.(e.pointerId); fromPoint(e); }} onPointerMove={(e) => e.buttons && fromPoint(e)} className="grid select-none gap-2 [touch-action:none]" style={{ gridTemplateColumns: `repeat(${COLS}, 1fr)` }} > {popped.map((p, i) => ( <span key={i} data-bubble={i} className={`h-8 w-8 rounded-full transition-[scale,background-color,border-color,box-shadow] duration-200 ease-[cubic-bezier(.5,1.8,.4,.8)] sm:h-9 sm:w-9 ${ p ? "scale-[.82] border border-dashed border-line bg-transparent" : "cursor-pointer bg-paper-2 shadow-[inset_-3px_-4px_8px_rgba(0,0,0,.45),inset_3px_3px_6px_rgba(233,233,228,.12)] hover:scale-105" }`} /> ))} </div> <div className="font-mono text-[11px] uppercase tracking-[0.08em] flex items-center gap-3 text-mute"> <span className="tabular-nums">{left} left</span> <span>·</span> <button type="button" onClick={() => setPopped(Array(COLS * ROWS).fill(false))} className={left === 0 ? "text-signal" : "hover:text-ink"}> Refill </button> </div> </div> ); }Or ask your AI agent
Paste this into Claude Code, Cursor, Codex, v0 or Lovable. Fill in the last line. More in Prompts.
Add the Astabyte UI Bubble wrap component to my project. Press to pop, or drag across to pop a whole row. It fills its parent, so give the wrapper a size. It is designed on a dark surface: put it inside an element with the `dark` class. Install it: ```sh pnpm dlx asta-ui@latest add bubble-wrap --radix ``` Or with the shadcn CLI: ```sh pnpm dlx shadcn@latest add https://ui.astabyte.com/r/bubble-wrap.json ``` If the project isn't set up yet, run `pnpm dlx asta-ui@latest init --radix` first: it runs `shadcn init` when needed and adds the @astabyte registry (Next.js, Vite, React Router, Astro, TanStack Start; Tailwind CSS v4). Import it like this: ```tsx import BubbleWrap from "@/components/astabyte/bubble-wrap"; ``` Usage example and props: https://ui.astabyte.com/bubble-wrap Full catalogue for context: https://ui.astabyte.com/llms.txt Rules: - Keep the colour tokens (paper, paper-2, ink, ink-2, mute, brand). Don't restyle with hard-coded colours; rebrand by changing the token values in the CSS. - Keep the motion as it is: transform and opacity only, and the prefers-reduced-motion fallback. - Keep keyboard, focus and ARIA behaviour. - Use fake data and fake brand names in examples. Use it to: [describe where it goes and what it should do]
Usage
It fills its parent. Give the wrapper a size.
import BubbleWrap from "@/components/astabyte/bubble-wrap";
export default function Page() {
// Bubble wrap
return (
<div className="relative h-96 w-full">
<BubbleWrap />
</div>
);
}