Product Grid 3
Bestseller rail: social proof through ranking. Products run down a rail of big accent numerals in their supplied rank,
Use it in a prompt
Use offer/product-grid-3 from the FunnelDNA library. Follow the skill and theme contract. Ask me for the copy, images, and brand details you need; do not invent proof.
Paste into Claude or ChatGPT with FunnelDNA connected (MCP setup), or alongside the skill.
Use it in code
- Save
component.tsx(Code tab) ascomponents/funneldna/offer/product-grid-3.tsx. - Import it and pass your copy and images (Props tab):
import { ProductGrid3 } from "@/components/funneldna/offer/product-grid-3"
It restyles from the theme tokens on any wrapper (Theme tab). The specimen source is a complete working example.
pieces/offer/product-grid-3/component.tsx 874 lines
// layout: number-rail
// Bestseller rail: social proof through ranking. Products run down a rail of big accent numerals in their supplied rank,
// each with its photo, the one reason people pick it, a supplied rating, a plain-spoken price and an add button; a list
// toggle (e.g. This month / All time) re-ranks the rail when two ranked lists are supplied, and a closing question is answered by the No. 1.
import * as React from 'react'
import { LayoutGroup, motion, useReducedMotion } from 'motion/react'
import { AlertCircle, Loader2, ShieldCheck, Star, Trophy } from 'lucide-react'
import { FX_HOST, Pattern } from '../fx/fx'
export type ProductGrid3Product = {
id: string // stable key, referenced by the ranked lists
name: string
image?: string // product photo (slot item-n), shown square
imageAlt?: string
imagePosition?: string // object-position focal point for the photo
reason?: React.ReactNode // the one line on why customers pick it
price: string
priceNote?: React.ReactNode // the value said in words beside the price, e.g. about 45¢ a cup
rating?: number // supplied average out of 5; omit when not supplied
reviewCount?: number | string
flag?: string // short true fact on the card, e.g. Caffeine-free
href?: string // product page for the name
rank?: number // supplied rank, used only when no lists are given
available?: boolean // false disables the add button
}
export type ProductGrid3List = {
id: string
label: string // toggle label, e.g. This month
short?: string // used in the cross-rank chip on the other list, e.g. all time
caption?: React.ReactNode // how this list is ranked, shown under the toggle
ranks: { product: string; rank: number }[] // product id and its supplied rank
}
export type ProductGrid3Selection = {
product: ProductGrid3Product
rank: number
list?: string // id of the list the visitor was looking at
}
export type ProductGrid3Copy = {
addLabel: string
addFor: string // screen-reader suffix on the add button; {name}
adding: string
soldOut: string
just: string // {price}
rankLabel: string // {rank}
otherRank: string // {rank}, {list}
ratingLabel: string // {rating}, {count}
ratingOnlyLabel: string // {rating}
reviews: string // {count}
addError: string
toggleLabel: string
listLabel: string // {list}
}
export type ProductGrid3Props = {
headline?: string
emphasis?: string // phrase inside the headline that gets the marker stroke
lead?: React.ReactNode
products?: ProductGrid3Product[]
lists?: ProductGrid3List[] // two or more ranked lists show the toggle
defaultList?: string // id of the list shown first
closeAsk?: React.ReactNode // the question under the rail; the button answers it
closeLabel?: string // answer button for the current No. 1; {name}, {rank}
note?: React.ReactNode // reassurance under the closing button (the supplied guarantee)
copy?: Partial<ProductGrid3Copy>
onAction?: (selection: ProductGrid3Selection) => void | Promise<unknown> // a returned promise shows loading; a rejection shows the inline error
state?: 'default' | 'hover' | 'active' | 'disabled' | 'error'
className?: string
}
const DEFAULT_COPY: ProductGrid3Copy = {
addLabel: 'Add to cart',
addFor: ', {name}',
adding: 'Adding…',
soldOut: 'Sold out',
just: 'Just {price}',
rankLabel: 'No. {rank}',
otherRank: 'No. {rank} {list}',
ratingLabel: 'Rated {rating} out of 5 from {count} reviews',
ratingOnlyLabel: 'Rated {rating} out of 5',
reviews: '({count} reviews)',
addError: 'We couldn’t add this to your cart. Please try again.',
toggleLabel: 'Show the bestsellers for',
listLabel: 'Bestsellers, {list}',
}
const EASE: [number, number, number, number] = [0.2, 0.7, 0.2, 1]
type RankedRow = { product: ProductGrid3Product; rank: number }
type RankedList = { list: ProductGrid3List; rows: RankedRow[] }
export function ProductGrid3(props: ProductGrid3Props) {
const {
headline = 'The ones people come back for',
emphasis = 'come back for',
lead = 'Ranked by what customers actually buy. Start where most people do.',
products = [],
lists = [],
defaultList,
closeAsk = 'Ready to try the one everyone keeps reordering?',
closeLabel = 'Yes, start me on {name}',
note,
copy: copyProp,
onAction,
state = 'default',
className,
} = props
const copy: ProductGrid3Copy = { ...DEFAULT_COPY, ...copyProp }
const reduce = useReducedMotion() ?? false
const uid = React.useId()
const headId = `${uid}-title`
const listId = `${uid}-list`
const [picked, setPicked] = React.useState<string | undefined>(defaultList)
const [busy, setBusy] = React.useState<string | null>(null)
const [errors, setErrors] = React.useState<Record<string, boolean>>({})
const alive = React.useRef(true)
React.useEffect(() => {
alive.current = true
return () => {
alive.current = false
}
}, [])
const byId = new Map(products.map((p) => [p.id, p] as const))
const ranked: RankedList[] = []
for (const list of lists) {
const rows = list.ranks
.map((r) => ({ product: byId.get(r.product), rank: r.rank }))
.filter((r): r is RankedRow => r.product !== undefined && Number.isFinite(r.rank))
.sort((a, b) => a.rank - b.rank)
if (rows.length) ranked.push({ list, rows })
}
if (!ranked.length) {
const rows = products
.filter((p) => typeof p.rank === 'number' && Number.isFinite(p.rank))
.map((p) => ({ product: p, rank: p.rank as number }))
.sort((a, b) => a.rank - b.rank)
if (rows.length) ranked.push({ list: { id: 'ranked', label: '', ranks: [] }, rows })
}
const current = ranked.find((r) => r.list.id === picked) ?? ranked[0]
if (!current) return null
const disabledAll = state === 'disabled'
const top = current.rows[0]
const hasToggle = ranked.length > 1
const otherFor = (id: string) => {
for (const r of ranked) {
if (r === current) continue
const hit = r.rows.find((x) => x.product.id === id)
if (hit) return { rank: hit.rank, list: r.list.short ?? r.list.label }
}
return null
}
const run = (key: string, selection: ProductGrid3Selection) => {
if (busy || disabledAll || selection.product.available === false) return
setErrors((e) => ({ ...e, [key]: false }))
let result: unknown
try {
result = onAction ? onAction(selection) : undefined
} catch {
setErrors((e) => ({ ...e, [key]: true }))
return
}
const pending = result as Promise<unknown> | undefined
if (pending && typeof pending.then === 'function') {
setBusy(key)
pending.then(
() => {
if (alive.current) setBusy(null)
},
() => {
if (alive.current) {
setBusy(null)
setErrors((e) => ({ ...e, [key]: true }))
}
},
)
}
}
const caption = current.list.caption
return (
<section
className={['cf-product-grid-3', className].filter(Boolean).join(' ')}
aria-labelledby={headId}
data-state={state}
style={FX_HOST}
>
<style>{CSS}</style>
<Pattern name='rings' fade='corner' />
<div className='pg3-wrap'>
<header className={hasToggle ? 'pg3-top' : 'pg3-top is-solo'}>
<div className='pg3-copy'>
<h2 id={headId} className='pg3-title'>
{withMark(headline, emphasis)}
</h2>
{lead ? <p className='pg3-lead'>{lead}</p> : null}
</div>
{hasToggle ? (
<div className='pg3-switch'>
<LayoutGroup id={`${uid}-tabs`}>
<div className='pg3-toggle' role='group' aria-label={copy.toggleLabel}>
{ranked.map(({ list }) => {
const on = list.id === current.list.id
return (
<button
key={list.id}
type='button'
className='pg3-tab'
aria-pressed={on}
aria-controls={listId}
onClick={() => setPicked(list.id)}
>
{on ? (
<motion.span
layoutId='pg3-pill'
className='pg3-pill'
aria-hidden='true'
transition={reduce ? { duration: 0 } : { type: 'spring', stiffness: 520, damping: 40 }}
/>
) : null}
<span className='pg3-tab-label'>{list.label}</span>
</button>
)
})}
</div>
</LayoutGroup>
<p className='pg3-caption' aria-live='polite'>
{caption}
</p>
</div>
) : caption ? (
<p className='pg3-caption pg3-caption-solo'>{caption}</p>
) : null}
</header>
<ol
id={listId}
className='pg3-list'
role='list'
aria-label={current.list.label ? fill(copy.listLabel, { list: current.list.label }) : undefined}
>
{current.rows.map((row, i) => {
const { product, rank } = row
const key = `row:${product.id}`
const errId = `${uid}-err-${i}`
const soldOut = product.available === false
const isBusy = busy === key
const showError = !!errors[key] || (state === 'error' && i === 0)
const other = hasToggle ? otherFor(product.id) : null
const hasRating = typeof product.rating === 'number' && Number.isFinite(product.rating)
const forced = i === 0 ? (state === 'hover' ? ' is-hover' : state === 'active' ? ' is-press' : '') : ''
return (
<li key={i} className={i === 0 ? 'pg3-row is-top' : 'pg3-row'}>
<div className='pg3-rail' aria-hidden='true'>
<span className='pg3-num'>{rank}</span>
</div>
<motion.article
key={`${current.list.id}:${product.id}`}
className={product.image ? 'pg3-card' : 'pg3-card no-photo'}
initial={reduce ? false : { opacity: 0.82, y: 8 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.45, ease: EASE, delay: Math.min(i * 0.07, 0.28) }}
>
{product.image ? (
<div className='pg3-photo'>
<img
src={product.image}
alt={product.imageAlt ?? product.name}
width={480}
height={480}
loading={i === 0 ? 'eager' : 'lazy'}
decoding='async'
style={{ objectPosition: product.imagePosition ?? '50% 50%' }}
/>
</div>
) : null}
<div className='pg3-info'>
{product.flag ? <span className='pg3-flag'>{product.flag}</span> : null}
<h3 className='pg3-name'>
<span className='pg3-sr'>{fill(copy.rankLabel, { rank })}: </span>
{product.href ? <a href={product.href}>{product.name}</a> : product.name}
</h3>
</div>
{hasRating ? (
<div className='pg3-rate'>
<Rating rating={product.rating as number} count={product.reviewCount} copy={copy} />
</div>
) : null}
{product.reason || other ? (
<div className='pg3-why'>
{product.reason ? <p className='pg3-reason'>{product.reason}</p> : null}
{other ? (
<span className='pg3-chip'>
<Trophy size={16} strokeWidth={2.5} aria-hidden='true' />
{fill(copy.otherRank, { rank: other.rank, list: other.list })}
</span>
) : null}
</div>
) : null}
<div className='pg3-buy'>
<p className='pg3-price'>
<span className='pg3-just'>{fill(copy.just, { price: product.price })}</span>
{product.priceNote ? <span className='pg3-worth'>{product.priceNote}</span> : null}
</p>
<button
type='button'
className={'pg3-btn' + forced}
disabled={disabledAll || soldOut}
aria-busy={isBusy || undefined}
aria-disabled={isBusy || undefined}
aria-describedby={showError ? errId : undefined}
onClick={() => run(key, { product, rank, list: current.list.id })}
>
{isBusy ? <Loader2 className='pg3-spin' size={20} strokeWidth={2.5} aria-hidden='true' /> : null}
<span>{isBusy ? copy.adding : soldOut ? copy.soldOut : copy.addLabel}</span>
<span className='pg3-sr'>{fill(copy.addFor, { name: product.name })}</span>
</button>
{showError ? (
<p id={errId} className='pg3-error' role='alert'>
<AlertCircle className='pg3-inline-icon' size={16} strokeWidth={2.5} aria-hidden='true' />
{copy.addError}
</p>
) : null}
</div>
</motion.article>
</li>
)
})}
</ol>
{closeAsk && top ? (
<CloseRow
ask={closeAsk}
image={top.product.image}
imagePosition={top.product.imagePosition}
label={fill(closeLabel, { name: top.product.name, rank: top.rank })}
note={note}
busy={busy === `close:${top.product.id}`}
error={!!errors[`close:${top.product.id}`]}
disabled={disabledAll || top.product.available === false}
copy={copy}
errId={`${uid}-err-close`}
onClick={() => run(`close:${top.product.id}`, { product: top.product, rank: top.rank, list: current.list.id })}
/>
) : note ? (
<p className='pg3-note pg3-note-solo'>
<ShieldCheck className='pg3-inline-icon' size={16} strokeWidth={2.5} aria-hidden='true' />
{note}
</p>
) : null}
</div>
</section>
)
}
export default ProductGrid3
function CloseRow(props: {
ask: React.ReactNode
image?: string
imagePosition?: string
label: string
note?: React.ReactNode
busy: boolean
error: boolean
disabled: boolean
copy: ProductGrid3Copy
errId: string
onClick: () => void
}) {
const { ask, image, imagePosition, label, note, busy, error, disabled, copy, errId, onClick } = props
return (
<div className='pg3-close'>
<div className='pg3-close-lead'>
{image ? (
<img
className='pg3-close-img'
src={image}
alt=''
width={144}
height={144}
loading='lazy'
decoding='async'
style={{ objectPosition: imagePosition ?? '50% 50%' }}
/>
) : null}
<p className='pg3-ask'>{ask}</p>
</div>
<div className='pg3-close-act'>
<button
type='button'
className='pg3-btn pg3-btn-lg'
disabled={disabled}
aria-busy={busy || undefined}
aria-disabled={busy || undefined}
aria-describedby={error ? errId : undefined}
onClick={onClick}
>
{busy ? <Loader2 className='pg3-spin' size={20} strokeWidth={2.5} aria-hidden='true' /> : null}
<span>{busy ? copy.adding : label}</span>
</button>
{error ? (
<p id={errId} className='pg3-error' role='alert'>
<AlertCircle className='pg3-inline-icon' size={16} strokeWidth={2.5} aria-hidden='true' />
{copy.addError}
</p>
) : null}
{note ? (
<p className='pg3-note'>
<ShieldCheck className='pg3-inline-icon' size={16} strokeWidth={2.5} aria-hidden='true' />
{note}
</p>
) : null}
</div>
</div>
)
}
function Rating(props: { rating: number; count?: number | string; copy: ProductGrid3Copy }) {
const { rating, count, copy } = props
const value = Number.isInteger(rating) ? rating.toFixed(1) : String(rating)
const countText = count === undefined || count === '' ? '' : typeof count === 'number' ? count.toLocaleString('en-US') : count
const pct = (Math.max(0, Math.min(5, rating)) / 5) * 100
const label = countText
? fill(copy.ratingLabel, { rating: value, count: countText })
: fill(copy.ratingOnlyLabel, { rating: value })
return (
<p className='pg3-rating' role='img' aria-label={label}>
<span className='pg3-stars' aria-hidden='true'>
<span className='pg3-stars-base'>{stars()}</span>
<span className='pg3-stars-fill' style={{ width: pct + '%' }}>
{stars()}
</span>
</span>
<span className='pg3-score' aria-hidden='true'>
{value}
</span>
{countText ? <span aria-hidden='true'>{fill(copy.reviews, { count: countText })}</span> : null}
</p>
)
}
function stars() {
return [0, 1, 2, 3, 4].map((n) => <Star key={n} size={16} strokeWidth={2.5} fill='currentColor' aria-hidden='true' />)
}
function withMark(text: string, phrase?: string): React.ReactNode {
if (!phrase) return text
const at = text.indexOf(phrase)
if (at < 0) return text
return (
<>
{text.slice(0, at)}
<span className='pg3-mark'>{phrase}</span>
{text.slice(at + phrase.length)}
</>
)
}
function fill(template: string, values: Record<string, string | number>) {
return Object.keys(values).reduce((out, k) => out.split('{' + k + '}').join(String(values[k])), template)
}
const CSS = `
.cf-product-grid-3 {
--pg3-gap: clamp(16px, 2.4vw, 24px);
--pg3-rail: clamp(40px, 11vw, 168px);
--pg3-col: clamp(12px, 2.4vw, 32px);
--pg3-numsize: clamp(2.75rem, 8vw, 7.5rem);
--pg3-shadow: var(--shadow, oklch(0.22 0.03 260));
--pg3-marker: var(--marker, color-mix(in oklch, #fae37c 78%, transparent));
position: relative;
isolation: isolate;
overflow: hidden;
background: var(--surface, #ffffff);
color: var(--ink, #172033);
font-family: var(--font-body, system-ui, sans-serif);
padding: clamp(56px, 8vw, 112px) clamp(16px, 5vw, 48px) clamp(64px, 8.5vw, 120px);
}
.cf-product-grid-3 *, .cf-product-grid-3 *::before, .cf-product-grid-3 *::after { box-sizing: border-box; }
.cf-product-grid-3 .pg3-wrap { position: relative; z-index: 1; max-width: 1120px; margin: 0 auto; }
.cf-product-grid-3 .pg3-sr {
position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
/* header */
.cf-product-grid-3 .pg3-top {
display: grid;
grid-template-columns: minmax(0, 1fr) auto;
align-items: end;
gap: 24px 48px;
margin: 0 0 clamp(32px, 4.5vw, 56px);
}
.cf-product-grid-3 .pg3-top.is-solo { grid-template-columns: minmax(0, 1fr); }
.cf-product-grid-3 .pg3-title {
margin: 0;
font-family: var(--font-display, inherit);
font-weight: var(--display-weight, 800);
letter-spacing: var(--display-tracking, -0.025em);
text-transform: var(--display-case, none);
font-size: clamp(2rem, 3.6vw, 3.25rem);
line-height: 1.06;
color: var(--ink, #172033);
text-wrap: balance;
}
.cf-product-grid-3 .pg3-mark {
padding: 0 0.08em;
margin: 0 -0.04em;
background-image: linear-gradient(176deg, transparent 0 50%, var(--pg3-marker) 50% 92%, transparent 92%);
border-radius: 0.14em 0.32em 0.2em 0.28em;
-webkit-box-decoration-break: clone;
box-decoration-break: clone;
}
.cf-product-grid-3 .pg3-lead {
margin: 16px 0 0;
max-width: 60ch;
font-size: clamp(1.125rem, 1.5vw, 1.375rem);
line-height: 1.4;
font-weight: 500;
color: var(--muted, #4a5568);
text-wrap: pretty;
}
.cf-product-grid-3 .pg3-switch { display: grid; justify-items: end; gap: 12px; }
.cf-product-grid-3 .pg3-toggle {
display: inline-flex;
gap: 4px;
padding: 4px;
border-radius: calc(var(--radius, 12px) + 4px);
background: color-mix(in oklch, var(--ink, #172033) 7%, var(--surface, #ffffff));
box-shadow: inset 0 0 0 1px oklch(from var(--ink, #172033) l c h / 0.06);
}
.cf-product-grid-3 .pg3-tab {
position: relative;
appearance: none;
border: 0;
cursor: pointer;
min-height: 48px;
padding: 0 22px;
border-radius: var(--radius, 12px);
background: transparent;
color: var(--ink, #172033);
font-family: var(--font-body, inherit);
font-size: clamp(1.0625rem, 1.25vw, 1.125rem);
font-weight: 700;
line-height: 1.15;
white-space: nowrap;
transition: background 0.16s ease;
}
.cf-product-grid-3 .pg3-tab[aria-pressed='true'] { font-weight: 800; }
.cf-product-grid-3 .pg3-tab[aria-pressed='false']:hover { background: color-mix(in oklch, var(--ink, #172033) 6%, transparent); }
.cf-product-grid-3 .pg3-tab:focus-visible { outline: 3px solid oklch(from var(--accent, oklch(0.5 0.17 257)) l c h / 0.55); outline-offset: 2px; }
.cf-product-grid-3 .pg3-pill {
position: absolute;
inset: 0;
z-index: 0;
border-radius: inherit;
background: var(--card, #ffffff);
box-shadow: inset 0 0 0 1.5px oklch(from var(--accent, oklch(0.5 0.17 257)) l c h / 0.5), var(--shadow-sm, 0 1px 1px oklch(from var(--pg3-shadow) l c h / 0.18), 0 1px 3px oklch(from var(--pg3-shadow) l c h / 0.14));
}
.cf-product-grid-3 .pg3-tab-label { position: relative; z-index: 1; }
.cf-product-grid-3 .pg3-caption {
margin: 0;
font-size: 0.9375rem;
line-height: 1.4;
font-weight: 600;
color: var(--muted, #4a5568);
text-align: right;
text-wrap: pretty;
}
.cf-product-grid-3 .pg3-caption:empty { display: none; }
.cf-product-grid-3 .pg3-caption-solo { align-self: end; }
/* rail */
.cf-product-grid-3 .pg3-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--pg3-gap); }
.cf-product-grid-3 .pg3-row {
position: relative;
display: grid;
grid-template-columns: minmax(var(--pg3-rail), max-content) minmax(0, 1fr);
gap: var(--pg3-col);
align-items: start;
}
.cf-product-grid-3 .pg3-rail { position: relative; align-self: stretch; display: flex; justify-content: center; min-width: 0; }
.cf-product-grid-3 .pg3-num {
display: block;
padding-top: 4px;
font-family: var(--font-display, inherit);
font-weight: var(--display-weight, 800);
font-size: var(--pg3-numsize);
line-height: 0.82;
letter-spacing: -0.04em;
font-variant-numeric: tabular-nums;
color: var(--accent, oklch(0.5 0.17 257));
}
.cf-product-grid-3 .pg3-row:not(:last-child) .pg3-rail::after {
content: '';
position: absolute;
left: 50%;
top: calc(var(--pg3-numsize) * 0.82 + 24px);
bottom: calc(var(--pg3-gap) * -1 + 8px);
width: 2px;
transform: translateX(-50%);
border-radius: 2px;
background: oklch(from var(--ink, #172033) l c h / 0.14);
}
/* card */
.cf-product-grid-3 .pg3-card {
--pg3-photo: clamp(150px, 16vw, 200px);
display: grid;
grid-template-columns: var(--pg3-photo) minmax(0, 1fr) minmax(200px, 240px);
grid-template-areas: 'photo head buy' 'photo rate buy' 'photo why buy';
grid-template-rows: auto auto 1fr;
align-items: start;
gap: 8px clamp(20px, 2.6vw, 32px);
padding: clamp(20px, 2.6vw, 28px);
background: var(--card, #ffffff);
color: var(--ink, #172033);
border: 1px solid var(--card-border, oklch(from var(--ink, #172033) l c h / 0.12));
border-radius: var(--card-radius, var(--radius, 14px));
box-shadow: var(--card-shadow, var(--shadow-md, 0 1px 2px oklch(from var(--pg3-shadow) l c h / 0.22), 0 4px 10px -2px oklch(from var(--pg3-shadow) l c h / 0.2)));
}
.cf-product-grid-3 .pg3-card.no-photo { grid-template-columns: minmax(0, 1fr) minmax(200px, 240px); grid-template-areas: 'head buy' 'rate buy' 'why buy'; }
/* the No. 1 is lifted and framed in the accent; same photo size so every row shares one text edge */
.cf-product-grid-3 .pg3-row.is-top .pg3-card {
border-color: oklch(from var(--accent, oklch(0.5 0.17 257)) l c h / 0.5);
box-shadow: var(--shadow-lg, 0 2px 4px oklch(from var(--pg3-shadow) l c h / 0.22), 0 12px 24px -8px oklch(from var(--pg3-shadow) l c h / 0.32));
}
.cf-product-grid-3 .pg3-photo {
grid-area: photo;
width: 100%;
aspect-ratio: 1;
overflow: hidden;
border-radius: 12px;
background: color-mix(in oklch, var(--ink, #172033) 4%, var(--card, #ffffff));
}
.cf-product-grid-3 .pg3-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.cf-product-grid-3 .pg3-info { grid-area: head; min-width: 0; }
.cf-product-grid-3 .pg3-flag {
display: inline-flex;
align-items: center;
min-height: 28px;
margin: 0 0 12px;
padding: 4px 12px;
border-radius: 999px;
font-size: 0.875rem;
font-weight: 800;
line-height: 1.2;
background: var(--accent-fill, var(--accent, oklch(0.5 0.17 257)));
color: var(--accent-fill-ink, var(--card, #ffffff));
}
.cf-product-grid-3 .pg3-name {
margin: 0;
font-family: var(--font-display, inherit);
font-weight: var(--display-weight, 800);
text-transform: var(--display-case, none);
font-size: clamp(1.3125rem, 1.8vw, 1.625rem);
line-height: 1.15;
letter-spacing: -0.01em;
text-wrap: balance;
}
.cf-product-grid-3 .pg3-name a { color: inherit; text-decoration: none; border-radius: 4px; }
.cf-product-grid-3 .pg3-name a:hover { text-decoration: underline; text-decoration-color: oklch(from var(--ink, #172033) l c h / 0.45); text-underline-offset: 0.18em; }
.cf-product-grid-3 .pg3-name a:focus-visible { outline: 3px solid oklch(from var(--accent, oklch(0.5 0.17 257)) l c h / 0.55); outline-offset: 3px; }
.cf-product-grid-3 .pg3-rating {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 4px 8px;
margin: 0;
font-size: 0.9375rem;
line-height: 1.4;
font-weight: 600;
color: var(--muted, #4a5568);
}
.cf-product-grid-3 .pg3-stars { position: relative; display: inline-flex; flex: 0 0 auto; }
.cf-product-grid-3 .pg3-stars-base, .cf-product-grid-3 .pg3-stars-fill { display: flex; gap: 2px; }
.cf-product-grid-3 .pg3-stars-base { color: oklch(from var(--ink, #172033) l c h / 0.18); }
.cf-product-grid-3 .pg3-stars-fill { position: absolute; top: 0; bottom: 0; left: 0; overflow: hidden; color: var(--accent-fill, var(--accent, oklch(0.5 0.17 257))); }
.cf-product-grid-3 .pg3-stars svg { flex: 0 0 auto; }
.cf-product-grid-3 .pg3-score { color: var(--ink, #172033); font-weight: 800; font-variant-numeric: tabular-nums; }
.cf-product-grid-3 .pg3-rate { grid-area: rate; min-width: 0; }
.cf-product-grid-3 .pg3-why { grid-area: why; min-width: 0; margin-top: 4px; }
.cf-product-grid-3 .pg3-reason {
margin: 0;
max-width: 60ch;
font-size: clamp(1.0625rem, 1.25vw, 1.125rem);
line-height: 1.5;
color: var(--ink, #172033);
text-wrap: pretty;
}
.cf-product-grid-3 .pg3-chip {
display: inline-flex;
align-items: center;
gap: 6px;
min-height: 28px;
margin-top: 12px;
padding: 4px 12px;
border-radius: 999px;
font-size: 0.875rem;
font-weight: 800;
line-height: 1.2;
background: color-mix(in oklch, var(--ink, #172033) 6%, var(--card, #ffffff));
color: var(--ink, #172033);
}
.cf-product-grid-3 .pg3-chip svg { flex: 0 0 auto; color: var(--accent, oklch(0.5 0.17 257)); }
/* price + action */
.cf-product-grid-3 .pg3-buy { grid-area: buy; display: grid; gap: 12px; align-content: start; min-width: 0; }
.cf-product-grid-3 .pg3-price { margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.cf-product-grid-3 .pg3-just {
font-family: var(--font-display, inherit);
font-weight: var(--display-weight, 800);
font-size: clamp(1.3125rem, 1.8vw, 1.625rem);
line-height: 1.15;
letter-spacing: -0.01em;
font-variant-numeric: tabular-nums;
color: var(--ink, #172033);
white-space: nowrap;
}
.cf-product-grid-3 .pg3-worth { font-size: 0.9375rem; line-height: 1.4; font-weight: 600; color: var(--muted, #4a5568); text-wrap: pretty; }
.cf-product-grid-3 .pg3-btn {
--pg3-bg: var(--button-bg, var(--cta, oklch(0.58 0.21 29)));
--pg3-bg2: var(--button-bg-2, var(--cta-2, oklch(0.51 0.21 29)));
appearance: none;
border: 0;
cursor: pointer;
display: inline-flex;
align-items: center;
justify-content: center;
gap: 10px;
width: 100%;
min-height: 56px;
padding: 10px 24px;
text-align: center;
text-wrap: balance;
font-family: var(--button-font, var(--font-display, inherit));
font-weight: var(--button-weight, 800);
text-transform: var(--button-case, none);
font-size: clamp(1.125rem, 1.55vw, 1.375rem);
line-height: 1.15;
color: var(--button-ink, var(--cta-ink, #ffffff));
text-shadow: var(--button-text-shadow, none);
border-radius: var(--button-radius, var(--radius, 12px));
background: linear-gradient(oklch(from var(--pg3-bg) calc(l + 0.04) c h), oklch(from var(--pg3-bg2) calc(l - 0.02) c h));
box-shadow: var(--button-shadow, inset 0 1px 0 oklch(from var(--pg3-bg) calc(l + 0.14) c h / 0.7), inset 0 -3px 0 oklch(from var(--pg3-bg) calc(l - 0.16) c h), 0 1px 2px oklch(from var(--pg3-shadow) l c h / 0.3), 0 8px 16px -6px oklch(from var(--pg3-shadow) l c h / 0.45));
transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}
.cf-product-grid-3 .pg3-btn:not(:disabled):hover, .cf-product-grid-3 .pg3-btn.is-hover:not(:disabled) {
background: linear-gradient(oklch(from var(--pg3-bg) calc(l - 0.01) c h), oklch(from var(--pg3-bg2) calc(l - 0.07) c h));
box-shadow: var(--button-shadow, inset 0 1px 0 oklch(from var(--pg3-bg) calc(l + 0.12) c h / 0.7), inset 0 -3px 0 oklch(from var(--pg3-bg) calc(l - 0.18) c h), 0 1px 2px oklch(from var(--pg3-shadow) l c h / 0.32), 0 10px 18px -6px oklch(from var(--pg3-shadow) l c h / 0.55));
transform: translateY(-1px);
}
.cf-product-grid-3 .pg3-btn:not(:disabled):active, .cf-product-grid-3 .pg3-btn.is-press:not(:disabled) {
transform: translateY(1px);
background: linear-gradient(oklch(from var(--pg3-bg) calc(l - 0.04) c h), oklch(from var(--pg3-bg2) calc(l - 0.08) c h));
box-shadow: inset 0 2px 4px oklch(from var(--pg3-bg) calc(l - 0.24) c h / 0.55), inset 0 -2px 0 oklch(from var(--pg3-bg) calc(l - 0.16) c h), 0 1px 1px oklch(from var(--pg3-shadow) l c h / 0.3);
}
.cf-product-grid-3 .pg3-btn:focus-visible { outline: 3px solid oklch(from var(--accent, oklch(0.5 0.17 257)) l c h / 0.55); outline-offset: 3px; }
.cf-product-grid-3 .pg3-btn[aria-busy='true'] { cursor: progress; }
.cf-product-grid-3 .pg3-btn:disabled {
cursor: not-allowed;
background: var(--button-2-bg, var(--secondary, oklch(0.93 0.015 263)));
color: var(--button-2-ink, var(--secondary-ink, var(--ink, #172033)));
text-shadow: none;
box-shadow: none;
transform: none;
}
.cf-product-grid-3 .pg3-btn-lg { min-height: 64px; padding: 12px 28px; }
.cf-product-grid-3 .pg3-spin { flex: 0 0 auto; animation: pg3-spin 0.8s linear infinite; }
@keyframes pg3-spin { to { transform: rotate(360deg); } }
.cf-product-grid-3 .pg3-inline-icon { display: inline-block; vertical-align: -0.15em; margin-inline-end: 0.4em; }
.cf-product-grid-3 .pg3-error {
margin: 0;
font-size: 0.9375rem;
line-height: 1.4;
font-weight: 600;
color: var(--danger, oklch(0.5 0.17 27));
text-wrap: pretty;
}
/* close: the question, answered by the No. 1 */
.cf-product-grid-3 .pg3-close {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 20px 32px;
margin: clamp(32px, 4.5vw, 56px) 0 0 calc(var(--pg3-rail) + var(--pg3-col));
padding: clamp(20px, 3vw, 32px);
border-radius: var(--card-radius, var(--radius, 14px));
background: color-mix(in oklch, var(--ink, #172033) 4%, var(--surface, #ffffff));
}
.cf-product-grid-3 .pg3-close-lead { flex: 1 1 18rem; display: flex; align-items: center; gap: 16px; min-width: 0; }
.cf-product-grid-3 .pg3-close-img {
flex: 0 0 auto;
display: block;
width: 72px;
height: 72px;
border-radius: 8px;
object-fit: cover;
}
.cf-product-grid-3 .pg3-ask {
flex: 1 1 auto;
min-width: 0;
margin: 0;
font-family: var(--font-display, inherit);
font-weight: var(--display-weight, 800);
text-transform: var(--display-case, none);
font-size: clamp(1.3125rem, 1.8vw, 1.625rem);
line-height: 1.15;
letter-spacing: -0.01em;
color: var(--ink, #172033);
text-wrap: balance;
}
.cf-product-grid-3 .pg3-close-act { flex: 0 1 auto; display: grid; gap: 12px; justify-items: center; min-width: min(100%, 340px); }
@media (min-width: 960px) {
.cf-product-grid-3 .pg3-btn-lg { white-space: nowrap; }
}
.cf-product-grid-3 .pg3-note {
margin: 0;
font-size: 0.9375rem;
line-height: 1.4;
font-weight: 600;
color: var(--muted, #4a5568);
text-align: center;
text-wrap: pretty;
}
.cf-product-grid-3 .pg3-note .pg3-inline-icon { color: var(--success, oklch(0.5 0.14 150)); }
.cf-product-grid-3 .pg3-note-solo { margin: 32px 0 0 calc(var(--pg3-rail) + var(--pg3-col)); text-align: left; }
@media (max-width: 959px) {
.cf-product-grid-3 .pg3-card { grid-template-columns: var(--pg3-photo) minmax(0, 1fr); grid-template-areas: 'photo head' 'photo rate' 'photo why' 'photo buy'; grid-template-rows: auto auto auto 1fr; }
.cf-product-grid-3 .pg3-card.no-photo { grid-template-columns: minmax(0, 1fr); grid-template-areas: 'head' 'rate' 'why' 'buy'; }
.cf-product-grid-3 .pg3-buy { max-width: 340px; margin-top: 8px; }
}
@media (max-width: 760px) {
.cf-product-grid-3 .pg3-top { grid-template-columns: minmax(0, 1fr); align-items: start; }
.cf-product-grid-3 .pg3-switch { justify-items: stretch; }
.cf-product-grid-3 .pg3-toggle { display: flex; }
.cf-product-grid-3 .pg3-tab { flex: 1 1 0; padding: 0 12px; }
.cf-product-grid-3 .pg3-caption { text-align: left; }
}
@media (max-width: 639px) {
.cf-product-grid-3 .pg3-card, .cf-product-grid-3 .pg3-row.is-top .pg3-card {
--pg3-photo: 80px;
grid-template-columns: var(--pg3-photo) minmax(0, 1fr);
grid-template-areas: 'photo head' 'rate rate' 'why why' 'buy buy';
grid-template-rows: auto;
gap: 12px 14px;
padding: 20px;
}
.cf-product-grid-3 .pg3-card.no-photo, .cf-product-grid-3 .pg3-row.is-top .pg3-card.no-photo { grid-template-columns: minmax(0, 1fr); grid-template-areas: 'head' 'rate' 'why' 'buy'; }
.cf-product-grid-3 .pg3-info { align-self: center; }
.cf-product-grid-3 .pg3-why { margin-top: 0; }
.cf-product-grid-3 .pg3-photo { border-radius: 8px; }
.cf-product-grid-3 .pg3-buy { max-width: none; margin-top: 4px; }
.cf-product-grid-3 .pg3-close { margin-left: 0; }
.cf-product-grid-3 .pg3-close-img { width: 56px; height: 56px; }
.cf-product-grid-3 .pg3-close-act { width: 100%; min-width: 0; }
.cf-product-grid-3 .pg3-note-solo { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
.cf-product-grid-3 .pg3-btn, .cf-product-grid-3 .pg3-tab { transition: none; }
.cf-product-grid-3 .pg3-btn:not(:disabled):hover, .cf-product-grid-3 .pg3-btn.is-hover:not(:disabled) { transform: none; }
.cf-product-grid-3 .pg3-spin { animation: none; }
}
`
pieces/offer/product-grid-3/specimen.tsx 102 lines
import __studioImage55217a6d from "../assets/d89a8e003dcd82e3.webp";
import __studioImage1cd6f98f from "../assets/65b0fbc5577100c1.webp";
import __studioImage81a99aba from "../assets/bc735d0cc41fff3b.webp";
import { ProductGrid3 } from '../product-grid-3'
import type { ProductGrid3List, ProductGrid3Product } from '../product-grid-3'
import defaults from '../../studio-defaults.json'
import { slot } from '../../slots'
export const states = ['default', 'hover', 'active', 'disabled', 'error']
type SpecimenState = 'default' | 'hover' | 'active' | 'disabled' | 'error'
export default function ProductGrid3Specimen({ state = 'default' }: { state?: SpecimenState }) {
const products: ProductGrid3Product[] = [
{
id: 'ember',
name: 'Ember Chai',
image: slot(
'item-1',
__studioImage55217a6d,
),
imageAlt: 'Terracotta tin of Kettlebloom Ember Chai with loose tea, cinnamon and cardamom',
reason: 'Bold enough for 7am, cosy enough to replace your second coffee.',
price: '$18',
priceNote: 'about 45¢ a cup',
rating: 4.9,
reviewCount: 1284,
},
{
id: 'moonlit',
name: 'Moonlit Chamomile',
flag: 'Caffeine-free',
image: slot(
'item-2',
__studioImage1cd6f98f,
),
imageAlt: 'Navy tin of Kettlebloom Moonlit Chamomile with dried chamomile flowers',
reason: 'The wind-down cup people brew at 9pm, night after night.',
price: '$16',
priceNote: 'about 40¢ a cup',
},
{
id: 'sencha',
name: 'Jade Sencha',
image: slot(
'item-3',
__studioImage81a99aba,
),
imageAlt: 'Sage green tin of Kettlebloom Jade Sencha with loose green tea and a cup',
reason: 'Clean and smooth, never bitter, even when you forget it in the pot.',
price: '$22',
priceNote: 'about 55¢ a cup',
rating: 4.8,
reviewCount: 2031,
},
]
const lists: ProductGrid3List[] = [
{
id: 'month',
label: 'This month',
short: 'this month',
caption: 'Ranked by orders in the last 30 days',
ranks: [
{ product: 'ember', rank: 1 },
{ product: 'moonlit', rank: 2 },
{ product: 'sencha', rank: 3 },
],
},
{
id: 'all',
label: 'All time',
short: 'all time',
caption: 'Ranked by every order since we opened',
ranks: [
{ product: 'sencha', rank: 1 },
{ product: 'ember', rank: 2 },
{ product: 'moonlit', rank: 3 },
],
},
]
return (
<ProductGrid3
headline='The Kettlebloom teas our regulars reorder most'
emphasis='reorder most'
lead='Ranked by real orders, not by us. Start with the cup everyone keeps coming back to.'
products={products}
lists={lists}
defaultList='month'
closeAsk='Ready for the cup everyone keeps reordering?'
closeLabel='Yes, start me on {name}'
note={defaults.sample.guarantee}
state={state}
onAction={() =>
new Promise<void>((resolve) => {
setTimeout(resolve, 700)
})
}
/>
)
}
| Name | Type | Details |
|---|---|---|
headline OptionalProductGrid3 |
string |
|
emphasis OptionalProductGrid3 |
string |
|
lead OptionalProductGrid3 |
React.ReactNode |
|
products OptionalProductGrid3 |
ProductGrid3Product[] |
|
lists OptionalProductGrid3 |
ProductGrid3List[] |
|
defaultList OptionalProductGrid3 |
string |
|
closeAsk OptionalProductGrid3 |
React.ReactNode |
|
closeLabel OptionalProductGrid3 |
string |
|
note OptionalProductGrid3 |
React.ReactNode |
|
copy OptionalProductGrid3 |
Partial<ProductGrid3Copy> |
|
onAction OptionalProductGrid3 |
(selection: ProductGrid3Selection) => void | Promise<unknown> |
|
state OptionalProductGrid3 |
'default' | 'hover' | 'active' | 'disabled' | 'error' |
|
className OptionalProductGrid3 |
string |
Theme roles it reads
Set by the theme bar, a preset or your brand. Colours come from the base tokens (--surface, --ink, --cta…) every piece uses.
--button-bg--button-bg-2--button-case--button-font--button-ink--button-radius--button-shadow--button-text-shadow--button-weight- Main CTA button: background, ink, font, weight, case, radius and shadow.
--button-2-bg--button-2-ink- Secondary button.
--card-border--card-radius--card-shadow- Cards and panels: radius, border and shadow.
--display-case--display-tracking--display-weight- Headlines: weight, letter case and tracking.
--marker- The highlighter colour behind key phrases.
Image slots
Filled from the brand’s images; the specimen ships its own defaults.
item-1- One image per offer item (item-1, item-2…), shown in stacks and lists.
item-2- One image per offer item (item-1, item-2…), shown in stacks and lists.
item-3- One image per offer item (item-1, item-2…), shown in stacks and lists.
-
65b0fbc5577100c1.webp
image/webp · 41.1 KB
-
b77916eca54aa689.webp
image/webp · 8.32 KB
-
bc735d0cc41fff3b.webp
image/webp · 35.6 KB
-
d435db6662febfcf.webp
image/webp · 10 KB
-
d89a8e003dcd82e3.webp
image/webp · 29.6 KB
-
f0a5d3e1e61804ba.webp
image/webp · 11.6 KB