Usage
import { ShopGrid } from './ShopGrid.jsx'
// Without callbacks the grid runs on its sample shelf. Wire it to your shop:
<ShopGrid
locale="en"
currency="USD"
items={catalog.products} // [{ id, type, name, notes, price, was, rating, reviews, stock, badge, image }]
categories={[{ id: 'beans', label: 'Beans' }, { id: 'gear', label: 'Brewing gear' }]}
saved={wishlist.ids}
bagCount={bag.count}
loading={catalog.loading}
error={catalog.error}
onRetry={catalog.reload}
onAdd={(product) => bag.add(product.id)}
onSave={(id, saved) => wishlist.toggle(id, saved)}
onOpenBag={() => 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 shelf. |
items | Array<{ id, type, name, notes?, price, was?, rating?, reviews?, stock?, badge?: 'new' | 'sale', image?, art?, tone? }> | sample shelf | The products. `type` puts a product in one of the `categories`, which make the filter tabs; `image` is its picture (without it, a plain box is drawn); `was` shows a struck price and the saving; a `stock` of five or fewer is shown. |
categories | Array<{ id, label }> | labels.types, then any other type on the shelf | The filter tabs, in order. Only categories that have products on the shelf are shown, each with its count. |
currency | string | by locale | ISO currency code for every price. |
saved | string[] | [] | Ids already saved; their hearts start filled. |
bagCount | number | 0 | Items already in the bag, shown on the bag button. |
loading | boolean | false | Shows skeleton cards while the shelf loads. |
error | boolean | string | false | Shows the error banner with a retry button; a string replaces its sentence. |
onAdd | (item) => Promise<void> | — | Quick add. The card button spins until it resolves, then shows a check. |
onSave | (id, saved) => void | — | A heart was filled or emptied. |
onOpenBag / onRetry | () => void | — | The bag button, and the retry button of the error banner. |
labels | object | — | Replaces any built-in text (keys as in copy.js), including the names of the kinds. |
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.
ShopGrid.jsxshop-grid.csscopy.jskit.jsxkit.cssui/base-button/ui/like-button/ui/empty-state/ui/status-tag/ui/alert-banner/ui/rating-stars/ui/select/ui/text-input/ui/skeleton-shimmer/ui/sliding-tabs/tokens.cssREADME.md
The block, its stylesheet and text, the shared kit, the components it uses and tokens.css install together into one folder.