Usage
import { ShopProduct } from './ShopProduct.jsx'
// Without callbacks the page runs on its sample tea. Your own pictures and facts replace the drawings:
const product = {
id: 'house-blend', name: 'House blend', kind: 'Coffee beans · medium roast', rating: 4.6, reviews: 88,
images: [{ src: '/img/blend-bag.jpg', label: 'The bag' }, { src: '/img/blend-beans.jpg', label: 'The beans' }],
specs: [{ icon: 'globe', label: 'Origin', value: 'Colombia' }, { icon: 'clock', label: 'Roasted', value: 'This week' }],
sizes: [{ id: '250', label: '250 g', price: 12, note: 'about 16 cups' }, { id: '1k', label: '1 kg', price: 38, stock: 4 }],
}
<ShopProduct
locale="en"
currency="USD"
freeFrom={80}
product={product}
soldOut={product.stock === 0}
saved={wishlist.has(product.id)}
bagCount={bag.count}
loading={loading}
error={error}
onRetry={reload}
onAdd={({ id, size, qty }) => bag.add(id, size, qty)}
onSave={(id, saved) => wishlist.toggle(id, saved)}
onNotify={(email, id) => restock.subscribe(email, id)}
onViewBag={() => router.push('/bag')}
/>Props
| Prop | Type | Default | What it does |
|---|---|---|---|
locale | 'en' | 'zh-CN' | 'es' | 'ja' | 'en' | Language of the built-in text and sample tea. |
product | { id, name, kind?, rating?, reviews?, tone?, notes?, notesLabel?, images?: Array<{ id?, src, label?, alt? }>, specs?: Array<{ icon?, label, value }>, specsLabel?, size?, sizes: Array<{ id, label, price, stock?, note?, noteIcon?, pack?: 'pouch' | 'tin' | 'big', cups? }>, brew? } | sample tea | The product. `images` are its pictures (without them the sample drawings show); `specs` are the facts under the button, each with a kit icon name or your own element; a size’s `note` stands beside the price. Each size has its own price; `size` is the one chosen first; a `stock` of five or fewer is shown. The sample’s `pack`, `cups` and `brew` still work. |
currency | string | by locale | ISO currency code for every price. |
freeFrom | number | by locale | Amount from which delivery is free, told beside the stock. |
soldOut | boolean | false | Shows the product as sold out, with the back-in-stock email instead of the add button. |
saved / bagCount | boolean / number | false / 0 | Whether the heart starts filled, and how many items the bag already holds. |
loading | boolean | false | Shows the skeleton of the page while it loads. |
error | boolean | string | false | Shows the error banner with a retry button; a string replaces its sentence. |
onAdd | ({ id, size, qty }) => Promise<void> | — | Adds to the bag; the button spins until it resolves, then a line confirms it. |
onSave | (id, saved) => void | — | The heart was filled or emptied. |
onNotify | (email, id) => Promise<void> | — | Saves the back-in-stock email of a sold-out product. |
onViewBag / onRetry | () => void | — | The link to the bag after an add, and the retry button of the error banner. |
labels | object | — | Replaces any built-in text (keys as in copy.js). |
className | string | — | Added to the root element; other attributes go there too. |
Add it to your project
Copy the prompt into Codex or Claude Code. The agent reads the published source, shows you what it will write and adds the block together with the components it is built from.
ShopProduct.jsxshop-product.csscopy.jskit.jsxkit.cssui/base-button/ui/like-button/ui/rolling-number/ui/status-tag/ui/alert-banner/ui/success-check/ui/number-input/ui/radio-group/ui/rating-stars/ui/text-input/ui/skeleton-shimmer/tokens.cssREADME.md
The block, its stylesheet and text, the shared kit, the components it uses and tokens.css install together into one folder.