Skip to Content
BBRICKSv0.7.4
KitPrimitives

ProductThumb

The v3 mock's .thumb.pimg: the store's product picture over the product's initials in the product's tone ink on the soft surface (radius 12, 44px by default; the mock's fallback). A picture that fails to load is dropped and the initials show. Decorative: the name is beside it.

import { ProductThumb } from '@ergasti/bricks';

Examples

Thumbnails

A product picture, or a tinted tile with its first letters when there is none or it fails.

Code
import { ProductThumb } from '@ergasti/bricks';
import { blocksData } from './sample-data';

function Thumbs() {
  return (
    <div style={{ display: 'flex', gap: 12, alignItems: 'center' }}>
      <ProductThumb name="Face powder" src={blocksData.photo(2)} />
      <ProductThumb name="Red lipstick" seed={0} />
      <ProductThumb name="Lash mascara" seed={3} src="data:image/png;base64,AAAA" size={56} />
    </div>
  );
}

Props

Prop

Type

Design guidance

How the BRICKS design system uses ProductThumb. Written in docs/content/components/ProductThumb.md; the props above are read from the code, which wins where the two disagree.

A rounded-square product picture with the product's initials as fallback; use it beside a product name in tables, pickers and drawer heads.

ProductThumb is the v3 mock's .thumb.pimg: a 12px-radius square (44px by default) on the soft surface showing up to two Jakarta 800 letters from the first two words of the name ("Red lipstick" → "RL") in the tone ink picked by seed. The store's picture, when given, covers the letters; one that fails to load is dropped and the letters show. It is decorative: the product name sits beside it.

Anatomy

  1. Square (span.kit-thumb, aria-hidden): width = height = size, --soft background, ink toneFor(seed)[1].
  2. Letters: up to two initials (Arabic kept apart with ZWNJ).
  3. Picture (img, optional): alt="", lazy, object-fit: cover, absolutely over the letters.

Variants

PropValueLookWhen
size44 (default)Table/list thumbProductCell, gift lists
size64LargeDrawer heads (product, gift)
seed0–4 (mod 5)Letter ink: --rasp-d, --olive, --butter-ink, --sky-ink, --lilac-inkUse the product id

States

StateTriggerLook
Picturesrc loadsPhoto
No picturesrc null/undefinedLetters on --soft
Broken picturesrc failsLetters (that src is not retried)

Usage

<ProductThumb name="Glow serum 30ml" src={p.image} seed={p.id} />

A product drawer head:

<DrawerHead tone="rasp" title="Glow serum 30ml" sub="EP-012"
  lead={<ProductThumb name="Glow serum 30ml" src={p.image} seed={p.id} size={64} />} />

In a table (what ProductCell composes):

interface Product { id: number; name: string; sku: string; sold: number }
const columns: DataColumn<Product>[] = [
  { key: 'name', label: 'Product', primary: true, sortKey: 'name', sortFirst: 'asc', render: (p) => <ProductCell name={p.name} sku={p.sku} sold={p.sold} seed={p.id} /> },
];

Where it appears

  • Brand › Analytics › Best-selling products table and product drawer head.
  • Brand › Motivation › gift products picker, gift stock list, gift drawer head.
  • Screens: Analytics, Motivation.

Guidelines

Do

  • Seed with the product id so each product keeps its colour.
  • Keep the name visible next to it.

Don't

RTL and Arabic

  • Arabic product names give Arabic letters, separated by ZWNJ so they never join.

Tokens

From CSS: --font-family-display (letters). Set inline: the var(--soft) background, and the letter ink from toneFor(seed): var(--rasp-d), var(--olive), var(--butter-ink), var(--sky-ink) or var(--lilac-ink).

Accessibility

  • aria-hidden, alt="": the name beside it is the accessible text.

Found in the source

  • ARIA attributes set: aria-hidden.
  • Its tests cover: “Arabic names give Arabic initials kept apart (ZWNJ); no src → initials only; nothing focusable”.

Read from the component's source and tests. See Accessibility for the patterns the library follows.

See also: AvatarStack · Button · ButtonLink

Source

src/kit/primitives/ProductThumb.tsx (line 16) on GitHub.

On this page