# Shop

An in-game store grid: category tabs, a featured deal row with countdowns, discounts, low stock, sold-out and owned states, a wallet check that greys out what the player cannot afford, and currency packs for real money. It only draws the shop. Your game keeps the wallet and the stock, and charges the player from the `onBuy` event.

Docs: https://cozy-ui.solo.engineer/docs/components/shop/

Install: `npx shadcn@latest add @cozy/shop`

### Usage

```tsx
import { Shop } from "@/components/ui/shop"
import { spend } from "@/components/ui/economy-core"

const [wallet, setWallet] = useState({ coin: 1250, gem: 40 })

<Shop
  title="General store"
  wallet={wallet}
  items={[
    { id: "rice", name: "Rice seeds", icon: <Grain />, price: { currency: "coin", amount: 20 } },
    { id: "moon", name: "Moon gem", icon: <Gem />, price: { currency: "gem", amount: 25 }, rarity: "legendary", stock: 3 },
  ]}
  onBuy={(item) => setWallet((w) => spend(w, item.price) ?? w)}
/>
```

### Props

| Prop | Type | Default | Description |
|---|---|---|---|
| items | `ShopItem<T>[]` | – | { id, name, label?, icon?, description?, price, rarity?, category?, badge?, discount?, stock?, soldOut?, owned?, limit?, endsAt?, featured?, kind?, amount?, bonus?, tag?, disabled?, data? }. `price` is a `Price` or an array of prices that are all paid. `icon` is a React node or an image URL. |
| wallet | `Wallet` | – | What the player has. Items the wallet cannot cover get a red price and a disabled Buy button (the card stays selectable). Without it nothing is greyed out. |
| currencies | `Record<string, Currency>` | `DEFAULT_CURRENCIES` | Names and icons of your currencies (coins and gems by default). |
| categories | `{ id, label, icon? }[]` | – | Tabs. An "All" tab is added first. Items match by `category`. |
| category / defaultCategory / onCategoryChange | `string / string / (id) => void` | `"all"` | Control the open tab. Use "all" for the first tab. |
| allLabel | `ReactNode` | `"All"` | Text of the first tab. |
| onBuy | `(item) => void` | – | Buy was pressed. Only called for items that can be bought (not sold out, owned, disabled or too expensive). Takes the money in your game. |
| onSelect | `(item) => void` | – | The card body was clicked or Enter was pressed on it, e.g. to open details. Works for every item. If you do not set it, clicking the card buys. |
| title / headerEnd | `ReactNode` | – | Header text and a slot at its end, e.g. a `CurrencyBar`. |
| refreshAt | `number` | – | Epoch ms of the next stock refresh. The header shows "New stock in 3h 12m" until then. |
| item.endsAt | `number` | – | Epoch ms when a deal ends. The card counts down and hides the countdown once the time has passed. |
| cardSize / columns | `number` | `168 / auto` | Minimum card width in px (cards grow to fill the row), or a fixed column count (it falls back to `cardSize` on narrow containers). Cards in a row share one height. |
| lowStock | `number` | `5` | Shows "3 left" when `stock` is at or below this. |
| sort | `(a, b) => number` | `items order` | Sort function for the featured row and the grid. |
| renderItem | `(item, state) => ReactNode` | – | Replace the inside of the card body. `state` is { soldOut, owned, affordable, canBuy, lowStock, featured }. Keep it non-interactive; the price and Buy button stay. |
| labels | `Partial<ShopLabels>` | `English` | buy, soldOut, owned, all, free, left(n), newStockIn(time), endsIn(time), bonus(bonus), discount(percent), notEnough. |
| emptyText / rarities / label | `ReactNode / Record<string, RarityConfig> / string` | `"Nothing for sale right now"` | Empty message, your own rarity set, and the accessible name of the list (defaults to the title). |

The Buy button reads "Buy" with the price shown above it. Real-money prices and free items put the price (or "Free") on the button instead, so a pack always says what it will charge.

Cards use a roving tabindex: Tab enters the grid once, arrow keys, Home and End move between cards, Enter buys or selects. Sold-out and owned cards say so to screen readers. Announcing a purchase (toast, aria-live) is up to your game.

Cozy UI never charges real money. For `{ real: "$4.99" }` items, call your store SDK (App Store, Google Play, Stripe) from `onBuy`.

### Example

```tsx
import * as React from "react";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import { CurrencyBar } from "@/components/ui/currency-bar";
import { spend, type Wallet } from "@/components/ui/economy-core";
import { Shop, type ShopItem } from "@/components/ui/shop";
import { STORE_CATEGORIES, storeItems, type StoreData } from "./shop-data";

export default function Demo() {
  const [items, setItems] = React.useState<ShopItem<StoreData>[]>(() => storeItems(Date.now()));
  const [wallet, setWallet] = React.useState<Wallet>({ coin: 1250, gem: 40 });
  const [refreshAt] = React.useState(() => Date.now() + 3 * 3_600_000 + 12 * 60_000);

  const buy = (item: ShopItem<StoreData>) => {
    const next = spend(wallet, item.price);
    if (!next) return;
    setWallet(next);
    setItems((all) => all.map((i) => (i.id !== item.id ? i : { ...i, owned: i.data?.once ? true : i.owned, stock: i.stock != null ? i.stock - 1 : i.stock })));
    toast.success(`Bought ${item.label ?? String(item.name)}`);
  };

  return (
    <Shop
      title="Village general store"
      items={items}
      wallet={wallet}
      categories={STORE_CATEGORIES}
      refreshAt={refreshAt}
      onBuy={buy}
      headerEnd={
        <div className="flex flex-wrap items-center gap-3">
          <CurrencyBar wallet={wallet} size="sm" />
          <Button size="sm" variant="outline" onClick={() => setWallet((w) => ({ ...w, coin: (w.coin ?? 0) + 500 }))}>+500 coins</Button>
        </div>
      }
    />
  );
}
```

### Source (components/ui/shop.tsx)

```tsx
import * as React from "react";
import { cn } from "@/lib/utils";
import { Button } from "@/components/ui/button";
import { canAfford, formatAmount, isRealPrice, priceLabel, PriceTag, DEFAULT_CURRENCIES, type Currency, type Price, type Wallet } from "./economy-core";
import { formatDuration, GameIcon, RarityBadge, rarityStyle, useNow, type Rarity, type RarityConfig } from "./game-core";

/* An in-game store: a grid of item cards with category tabs, featured deals,
   countdowns, discounts, sold-out / owned states and currency packs. It only
   draws the shop. The game owns the wallet and stock, and charges the player
   (or real money) from the `onBuy` event. */

export type ShopItem<T = unknown> = {
  /** Stable id. */
  id: string;
  /** Display name. */
  name: React.ReactNode;
  /** Plain-text name for accessible labels. Defaults to `name` when it is a string, else the id. */
  label?: string;
  /** A React node (SVG, sprite) or an image URL. */
  icon?: React.ReactNode;
  /** Short text under the name (two lines are shown, the rest is cut). */
  description?: React.ReactNode;
  /** What it costs: one price, or several that are all paid, e.g. `[{ currency: "coin", amount: 50 }, { currency: "gem", amount: 2 }]`. Use `{ real: "$4.99" }` for real money and "free" for gifts. */
  price: Price | Price[];
  /** Tints the card and shows a rarity badge. */
  rarity?: Rarity;
  /** Category id; matches an entry of `categories`. Items without one only show in the "All" tab. */
  category?: string;
  /** A small corner tag, e.g. "New". */
  badge?: React.ReactNode;
  /** Percent off, shown as "-20%". The price itself comes from `price` (use `was` there to strike out the old price). */
  discount?: number;
  /** Units left. 0 means sold out; a small number shows "3 left" (see `lowStock`). */
  stock?: number;
  /** Marks the item as sold out regardless of `stock`. */
  soldOut?: boolean;
  /** For one-time items the player already has. Shows "Owned" and blocks buying. */
  owned?: boolean;
  /** Purchase limit as text, e.g. "1 per day". */
  limit?: string;
  /** When a deal ends (epoch ms). The card shows a live countdown until then; the countdown is hidden once the time has passed. */
  endsAt?: number;
  /** Shows the item as a wide card in a row above the grid. */
  featured?: boolean;
  /** "pack" draws a currency pack (big amount, bonus ribbon, price button). Default "item". */
  kind?: "item" | "pack";
  /** Packs: how much the pack gives, shown big as "×500". */
  amount?: number;
  /** Packs: the bonus, shown on a ribbon, e.g. "+20%". */
  bonus?: React.ReactNode;
  /** A ribbon across the top of the card, e.g. "Best value". */
  tag?: React.ReactNode;
  /** Blocks buying (the card stays selectable and dimmed), e.g. while a level requirement is not met. */
  disabled?: boolean;
  /** Anything your game needs; passed back in callbacks. */
  data?: T;
};

export type ShopCategory = {
  /** Stable id, matches `ShopItem.category`. */
  id: string;
  /** Tab text. */
  label: React.ReactNode;
  /** A React node or an image URL shown before the label. */
  icon?: React.ReactNode;
};

/** What `renderItem` gets to know about the card. */
export type ShopItemState = {
  /** The item is sold out (`soldOut` or `stock` is 0). */
  soldOut: boolean;
  /** The item is owned. */
  owned: boolean;
  /** The wallet covers the price (true when no wallet is given). */
  affordable: boolean;
  /** Not sold out, not owned, not disabled, and affordable. */
  canBuy: boolean;
  /** Stock is at or under `lowStock`. */
  lowStock: boolean;
  /** The card is in the featured row. */
  featured: boolean;
};

/** Every built-in string. Pass only the ones you change. */
export type ShopLabels = {
  /** Default "Buy". */
  buy: string;
  /** Default "Sold out". */
  soldOut: string;
  /** Default "Owned". */
  owned: string;
  /** Default "All". */
  all: string;
  /** Text on the buy button for free items. Default "Free". */
  free: string;
  /** Stock text. Default `${n} left`. */
  left: (n: number) => string;
  /** Header text; `time` is like "3h 12m". Default `New stock in ${time}`. */
  newStockIn: (time: string) => string;
  /** Deal countdown text. Default `Ends in ${time}`. */
  endsIn: (time: string) => string;
  /** Ribbon text for a pack bonus. Default `${bonus} bonus`. */
  bonus: (bonus: React.ReactNode) => React.ReactNode;
  /** Screen reader text for the discount. Default `${n}% off`. */
  discount: (percent: number) => string;
  /** Screen reader text when the wallet is short. Default "not enough". */
  notEnough: string;
};

const DEFAULT_LABELS: ShopLabels = {
  buy: "Buy",
  soldOut: "Sold out",
  owned: "Owned",
  all: "All",
  free: "Free",
  left: (n) => `${n} left`,
  newStockIn: (t) => `New stock in ${t}`,
  endsIn: (t) => `Ends in ${t}`,
  bonus: (b) => <>{b} bonus</>,
  discount: (n) => `${n}% off`,
  notEnough: "not enough",
};

type ShopProps<T> = Omit<React.ComponentProps<"div">, "children" | "title" | "onSelect"> & {
  /** What is for sale. */
  items: ShopItem<T>[];
  /** What the player has, e.g. `{ coin: 1250, gem: 40 }`. With it, items the player cannot pay for show a red price and a disabled Buy button. Without it, nothing is greyed out. */
  wallet?: Wallet;
  /** Names and icons of your currencies. Default coins and gems. */
  currencies?: Record<string, Currency>;
  /** Category tabs. Items match by `category`. An "All" tab is added in front. */
  categories?: ShopCategory[];
  /** Text of the first tab. Default "All". */
  allLabel?: React.ReactNode;
  /** Controlled category id ("all" for the first tab). */
  category?: string;
  /** Starting category when uncontrolled. Default "all". */
  defaultCategory?: string;
  /** Called with the new category id when a tab is chosen. */
  onCategoryChange?: (id: string) => void;
  /** The Buy button was pressed (or Enter, or a card click when `onSelect` is not set). Only fires for items that can be bought. */
  onBuy?: (item: ShopItem<T>) => void;
  /** The card body was clicked or Enter was pressed on it, e.g. to open details. Also works for sold-out and unaffordable items. */
  onSelect?: (item: ShopItem<T>) => void;
  /** Shop title. */
  title?: React.ReactNode;
  /** When the stock refreshes (epoch ms). The header shows "New stock in 3h 12m" until then. */
  refreshAt?: number;
  /** A slot at the end of the header, e.g. a `CurrencyBar`. */
  headerEnd?: React.ReactNode;
  /** Shown when no item matches. Default "Nothing for sale right now". */
  emptyText?: React.ReactNode;
  /** Minimum card width in px; cards grow to fill the row. Default 168. */
  cardSize?: number;
  /** A fixed number of columns instead of fitting as many as `cardSize` allows. */
  columns?: number;
  /** Shows "N left" when stock is at or below this number. Default 5. */
  lowStock?: number;
  /** Sort the items (the featured row and the grid each keep this order). Default: the order of `items`. */
  sort?: (a: ShopItem<T>, b: ShopItem<T>) => number;
  /** Your own rarity set. */
  rarities?: Record<string, RarityConfig>;
  /** Replace what is inside a card's clickable body (art, name, text). Keep it non-interactive; the price and Buy button stay. */
  renderItem?: (item: ShopItem<T>, state: ShopItemState) => React.ReactNode;
  /** Replace built-in strings (localisation). */
  labels?: Partial<ShopLabels>;
  /** Accessible name of the item list. Defaults to the title, else "Shop". */
  label?: string;
};

const plain = (i: ShopItem<unknown>) => i.label ?? (typeof i.name === "string" ? i.name : i.id);

const ClockIcon = () => (
  <svg viewBox="0 0 16 16" width="1em" height="1em" aria-hidden fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round">
    <circle cx="8" cy="8" r="6" />
    <path d="M8 4.5V8l2.2 1.5" />
  </svg>
);

/** Text that counts down to `endsAt` on its own (only this node re-renders). Renders nothing once the time has passed. */
function Countdown({ endsAt, format, className }: { endsAt: number; format: (time: string) => React.ReactNode; className?: string }) {
  const now = useNow(1000, true);
  const left = endsAt - now;
  if (left <= 0) return null;
  return <span className={className}><ClockIcon /> <span>{format(formatDuration(left, "short"))}</span></span>;
}

function Shop<T = unknown>({
  items, wallet, currencies = DEFAULT_CURRENCIES, categories, allLabel, category: categoryProp, defaultCategory = "all", onCategoryChange,
  onBuy, onSelect, title, refreshAt, headerEnd, emptyText = "Nothing for sale right now", cardSize = 168, columns, lowStock = 5, sort,
  rarities, renderItem, labels: labelsProp, label, className, style, ...props
}: ShopProps<T>) {
  const L = { ...DEFAULT_LABELS, ...labelsProp };
  const uid = React.useId();
  const [catInner, setCatInner] = React.useState(defaultCategory);
  const category = categoryProp !== undefined ? categoryProp : catInner;
  const [focus, setFocus] = React.useState(0);
  const [cols, setCols] = React.useState({ main: 3, featured: 2 });
  const mainRef = React.useRef<HTMLDivElement>(null);
  const featRef = React.useRef<HTMLDivElement>(null);
  const rootRef = React.useRef<HTMLDivElement>(null);

  const setCategory = (id: string) => {
    if (categoryProp === undefined) setCatInner(id);
    setFocus(0);
    onCategoryChange?.(id);
  };

  const shown = items.filter((i) => category === "all" || i.category === category);
  const ordered = sort ? [...shown].sort(sort) : shown;
  const featured = ordered.filter((i) => i.featured);
  const regular = ordered.filter((i) => !i.featured);
  const all = [...featured, ...regular];
  const nf = featured.length;

  React.useEffect(() => {
    const count = (el: HTMLElement | null, fallback: number) => (el ? Math.max(1, getComputedStyle(el).gridTemplateColumns.split(" ").filter(Boolean).length) : fallback);
    const measure = () => setCols((c) => {
      const next = { main: count(mainRef.current, c.main), featured: count(featRef.current, c.featured) };
      return next.main === c.main && next.featured === c.featured ? c : next;
    });
    measure();
    const ro = new ResizeObserver(measure);
    for (const el of [mainRef.current, featRef.current]) if (el) ro.observe(el);
    return () => ro.disconnect();
  }, [nf, regular.length, columns, cardSize]);

  const focusPos = (p: number) => {
    const n = Math.max(0, Math.min(all.length - 1, p));
    setFocus(n);
    rootRef.current?.querySelector<HTMLElement>(`[data-pos="${n}"]`)?.focus();
  };
  const onGridKeyDown = (e: React.KeyboardEvent) => {
    if (e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey || all.length === 0) return;
    const cur = Math.min(focus, all.length - 1);
    let next: number | null = null;
    if (e.key === "ArrowLeft") next = cur - 1;
    else if (e.key === "ArrowRight") next = cur + 1;
    else if (e.key === "ArrowDown" || e.key === "ArrowUp") {
      const dir = e.key === "ArrowDown" ? 1 : -1;
      if (cur < nf) {
        // in the featured row
        if (dir === 1) next = cur + cols.featured < nf ? cur + cols.featured : regular.length > 0 ? nf + Math.min(cur % cols.featured, regular.length - 1) : cur;
        else next = cur - cols.featured >= 0 ? cur - cols.featured : cur;
      } else {
        const i = cur - nf;
        const t = i + dir * cols.main;
        if (t < 0) next = nf > 0 ? Math.min(i, nf - 1) : cur;
        else next = nf + Math.min(t, regular.length - 1);
      }
    } else if (e.key === "Home") next = 0;
    else if (e.key === "End") next = all.length - 1;
    if (next == null) return;
    e.preventDefault();
    focusPos(next);
  };

  const tabs: ShopCategory[] = categories?.length ? [{ id: "all", label: allLabel ?? L.all }, ...categories] : [];
  const onTabKeyDown = (e: React.KeyboardEvent) => {
    const i = Math.max(0, tabs.findIndex((t) => t.id === category));
    const map: Record<string, number> = { ArrowLeft: i - 1, ArrowRight: i + 1, Home: 0, End: tabs.length - 1 };
    if (!(e.key in map)) return;
    e.preventDefault();
    const n = (map[e.key] + tabs.length) % tabs.length;
    setCategory(tabs[n].id);
    requestAnimationFrame(() => rootRef.current?.querySelector<HTMLElement>(`[data-tab="${tabs[n].id}"]`)?.focus());
  };

  const name = label ?? (typeof title === "string" ? title : "Shop");

  const renderCard = (item: ShopItem<T>, pos: number, isFeatured: boolean) => {
    const plist = Array.isArray(item.price) ? item.price : [item.price];
    const real = plist.find(isRealPrice);
    const isFree = plist.every((p) => p === "free");
    const soldOut = !!item.soldOut || item.stock === 0;
    const owned = !!item.owned;
    const affordable = wallet === undefined || canAfford(item.price, wallet);
    const canBuy = !soldOut && !owned && !item.disabled && affordable;
    const low = item.stock != null && item.stock > 0 && item.stock <= lowStock;
    const isPack = item.kind === "pack";
    const state: ShopItemState = { soldOut, owned, affordable, canBuy, lowStock: low, featured: isFeatured };
    const n = plain(item);
    const priceText = plist.map((p) => priceLabel(p, currencies)).join(" + ");
    const roving = pos === Math.min(focus, all.length - 1) ? 0 : -1;
    const buyHere = () => { if (canBuy) onBuy?.(item); };
    const onBody = () => { if (onSelect) onSelect(item); else buyHere(); };
    const buttonText = real ? real.real : isFree ? L.free : L.buy;
    const off = item.discount != null && item.discount > 0;

    return (
      <div role="listitem" key={item.id} className="cz-shop__cell">
        <div
          className="cz-shop__item"
          data-featured={isFeatured || undefined}
          data-kind={isPack ? "pack" : "item"}
          data-sold-out={soldOut || undefined}
          data-owned={owned || undefined}
          data-short={!affordable || undefined}
          data-disabled={item.disabled || undefined}
          data-rarity={item.rarity}
          data-has-tag={item.tag != null || undefined}
          style={rarityStyle(item.rarity, rarities)}
        >
          <button type="button" className="cz-shop__body" data-pos={pos} tabIndex={roving} onFocus={() => setFocus(pos)} onClick={onBody}>
            {renderItem ? renderItem(item, state) : (
              <>
                <span className="cz-shop__art"><GameIcon icon={item.icon} alt="" /></span>
                <span className="cz-shop__text">
                  {isPack && item.amount != null && <span className="cz-shop__amount">×{formatAmount(item.amount)}</span>}
                  <span className="cz-shop__name">{item.name}</span>
                  {item.description != null && <span className="cz-shop__desc">{item.description}</span>}
                  {!isPack && item.rarity && <RarityBadge rarity={item.rarity} rarities={rarities} className="cz-shop__rarity" />}
                  {(low || item.limit || item.endsAt != null) && (
                    <span className="cz-shop__meta">
                      {low && <span className="cz-shop__stock">{L.left(item.stock as number)}</span>}
                      {item.limit && <span className="cz-shop__limit">{item.limit}</span>}
                      {item.endsAt != null && <Countdown endsAt={item.endsAt} format={L.endsIn} className="cz-shop__deal" />}
                    </span>
                  )}
                </span>
              </>
            )}
            {(soldOut || owned) && <span className="cz-sr-only">, {soldOut ? L.soldOut : L.owned}</span>}
            {off && <span className="cz-sr-only">, {L.discount(item.discount as number)}</span>}
            {item.badge != null && <span className="cz-shop__badge">{item.badge}</span>}
            {(off || item.bonus != null) && (
              <span className="cz-shop__flags">
                {off && <span className="cz-shop__discount" aria-hidden>-{item.discount}%</span>}
                {item.bonus != null && <span className="cz-shop__bonus">{L.bonus(item.bonus)}</span>}
              </span>
            )}
          </button>
          {item.tag != null && <span className="cz-shop__ribbon">{item.tag}</span>}
          <div className="cz-shop__foot">
            {soldOut ? (
              <span className="cz-shop__state" data-state="sold-out">{L.soldOut}</span>
            ) : owned ? (
              <span className="cz-shop__state" data-state="owned">
                <svg viewBox="0 0 16 16" width="1em" height="1em" aria-hidden fill="none" stroke="currentColor" strokeWidth="2.6" strokeLinecap="round" strokeLinejoin="round"><path d="M3 8.5 6.5 12 13 4.5" /></svg>
                {L.owned}
              </span>
            ) : (
              <>
                {!real && !isFree && (
                  <span className="cz-shop__price" aria-hidden>
                    {plist.map((p, i) => <PriceTag key={i} price={p} currencies={currencies} wallet={wallet} freeLabel={L.free} />)}
                  </span>
                )}
                <Button
                  size="sm"
                  variant={real ? "reward" : "success"}
                  className="cz-shop__buy"
                  disabled={!canBuy}
                  tabIndex={roving}
                  aria-label={`${L.buy} ${n}, ${priceText}${!affordable ? `, ${L.notEnough}` : ""}`}
                  onClick={buyHere}
                >
                  {real?.was != null && <s className="cz-shop__was">{real.was}</s>}
                  {buttonText}
                </Button>
              </>
            )}
          </div>
        </div>
      </div>
    );
  };

  const gridStyle = columns ? ({ "--cols": columns } as React.CSSProperties) : undefined;
  const panelProps = tabs.length ? { role: "tabpanel", id: `${uid}-panel`, "aria-labelledby": `${uid}-tab-${category}` } : {};

  return (
    <div ref={rootRef} data-slot="shop" className={cn("cz-shop", className)} style={{ "--card": `${cardSize}px`, ...style } as React.CSSProperties} {...props}>
      {(title != null || refreshAt != null || headerEnd != null) && (
        <div className="cz-shop__head">
          {title != null && <div className="cz-shop__title">{title}</div>}
          {refreshAt != null && <Countdown endsAt={refreshAt} format={L.newStockIn} className="cz-shop__refresh" />}
          {headerEnd != null && <div className="cz-shop__head-end">{headerEnd}</div>}
        </div>
      )}
      {tabs.length > 0 && (
        <div className="cz-shop__tabs" role="tablist" aria-label={`${name} categories`} onKeyDown={onTabKeyDown}>
          {tabs.map((t) => (
            <button
              key={t.id}
              type="button"
              role="tab"
              id={`${uid}-tab-${t.id}`}
              data-tab={t.id}
              aria-selected={category === t.id}
              aria-controls={`${uid}-panel`}
              tabIndex={category === t.id ? 0 : -1}
              className="cz-shop__tab"
              onClick={() => setCategory(t.id)}
            >
              {t.icon != null && <span className="cz-shop__tab-icon"><GameIcon icon={t.icon} alt="" /></span>}
              {t.label}
            </button>
          ))}
        </div>
      )}
      <div className="cz-shop__panel" {...panelProps} onKeyDown={onGridKeyDown}>
        {nf > 0 && (
          <div ref={featRef} role="list" aria-label={`${name}, featured`} className="cz-shop__featured">
            {featured.map((it, i) => renderCard(it, i, true))}
          </div>
        )}
        {regular.length > 0 && (
          <div ref={mainRef} role="list" aria-label={name} className="cz-shop__grid" data-fixed={columns ? "" : undefined} style={gridStyle}>
            {regular.map((it, i) => renderCard(it, nf + i, false))}
          </div>
        )}
        {all.length === 0 && <div className="cz-shop__empty">{emptyText}</div>}
      </div>
    </div>
  );
}

export { Shop, DEFAULT_LABELS as DEFAULT_SHOP_LABELS };
export type { ShopProps };
```

npm: `import { Shop, DEFAULT_LABELS as DEFAULT_SHOP_LABELS } from "@0xtrou/cozy-ui"` (after `npm install @0xtrou/cozy-ui` and `import "@0xtrou/cozy-ui/styles.css"`).
