Skip to content
All blocks

[35] E-commerce

Product Grid

Eight products with a square shot, the name, the price, color swatches and a sale badge, under a sort menu.

1280px

Copy the code

One file with one component and its sample data. It needs @vaneui/ui and its stylesheet, set up as in the installation guide.

product-grid.tsx

import type { ReactNode } from "react";
import { Badge, Card, Col, Container, Grid4, Icon, Row, Section, SectionTitle, Select, Text } from "@vaneui/ui";
function Svg({ children }: { children: ReactNode }) {
return (
<svg width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
{children}
</svg>
);
}
// Product shots are drawn: a tinted square with an outline, so the grid needs no images to look finished
const products: { name: string; href: string; price: string; was?: string; colors: [string, string][]; tone: object; shot: ReactNode }[] = [
{ name: "Everyday tee", href: "/shop/everyday-tee", price: "$32", colors: [["Sand", "#d8c7a8"], ["Black", "#1f2328"], ["Sage", "#a3b18a"]], tone: { warning: true },
shot: <Svg><path d="M8 3 3 6l2 5 3-1v11h8V10l3 1 2-5-5-3a4 4 0 0 1-8 0z" /></Svg> },
{ name: "Stoneware mug", href: "/shop/stoneware-mug", price: "$18", colors: [["Sage", "#a3b18a"], ["Chalk", "#efece6"]], tone: { success: true },
shot: <Svg><path d="M5 8h12v6a5 5 0 0 1-5 5h-2a5 5 0 0 1-5-5zM17 10h1.5a2.5 2.5 0 0 1 0 5H17M8 3v2M12 3v2" /></Svg> },
{ name: "Canvas tote", href: "/shop/canvas-tote", price: "$24", was: "$30", colors: [["Natural", "#e9dfcc"], ["Navy", "#2b3a55"]], tone: { info: true },
shot: <Svg><path d="M4 8h16l-1 13H5zM9 8V6a3 3 0 0 1 6 0v2" /></Svg> },
{ name: "Wool beanie", href: "/shop/wool-beanie", price: "$28", colors: [["Rust", "#b5552b"], ["Charcoal", "#3c3f44"], ["Oat", "#d9cdb8"]], tone: { danger: true },
shot: <Svg><path d="M5 16a7 7 0 0 1 14 0M4 16h16v3H4zM12 6V4" /></Svg> },
{ name: "Linen shirt", href: "/shop/linen-shirt", price: "$64", colors: [["White", "#f4f1ea"], ["Olive", "#6b6f3a"]], tone: { secondary: true },
shot: <Svg><path d="M9 3h6l5 3-2 5-2-1v11H8V10l-2 1-2-5zM12 3v18" /></Svg> },
{ name: "Gift box", href: "/shop/gift-box", price: "$6", colors: [["Kraft", "#c49a6c"]], tone: { warning: true },
shot: <Svg><path d="m12 3 8 4.5v9L12 21l-8-4.5v-9z" /><path d="m4 7.5 8 4.5 8-4.5M12 12v9" /></Svg> },
{ name: "Dot notebook", href: "/shop/dot-notebook", price: "$12", was: "$16", colors: [["Ink", "#26324a"], ["Clay", "#c27c5c"]], tone: { info: true },
shot: <Svg><path d="M6 3h12v18H6zM9 3v18M12 8h3M12 12h3" /></Svg> },
{ name: "Steel bottle", href: "/shop/steel-bottle", price: "$26", colors: [["Steel", "#b8bcc2"], ["Forest", "#2f4a3a"]], tone: { success: true },
shot: <Svg><path d="M10 2h4v3h-4zM9 5h6l1 3v13H8V8z" /></Svg> },
];
export function ProductGrid() {
return (
<Section>
<Container itemsStretch>
<Col lg>
<Row justifyBetween itemsEnd flexWrap>
<Col xs>
<SectionTitle>New arrivals</SectionTitle>
<Text secondary>{products.length} products, made to last.</Text>
</Col>
<Select aria-label="Sort by" defaultValue="featured" wFit>
<option value="featured">Featured</option>
<option value="price-asc">Price, low to high</option>
<option value="price-desc">Price, high to low</option>
<option value="newest">Newest</option>
</Select>
</Row>
<Grid4 lg>
{products.map((p) => (
<Col key={p.href} href={p.href} sm>
<Card {...p.tone} aspectSquare itemsCenter justifyCenter relative aria-hidden="true">
{p.was && <Badge danger filled absolute className="top-3 left-3">Sale</Badge>}
{p.shot}
</Card>
<Row justifyBetween itemsStart>
<Text sm fontMedium>{p.name}</Text>
<Text sm fontSemibold className="tabular-nums">
{p.was && <Text tag="s" sm tertiary fontNormal>{p.was}</Text>} {p.price}
</Text>
</Row>
<Row xs>
{p.colors.map(([name, hex]) => (
<Icon key={name} xs tertiary>
<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10" fill={hex} stroke="currentColor" strokeWidth="2" /></svg>
</Icon>
))}
<Text xs tertiary>{p.colors.length === 1 ? "1 color" : `${p.colors.length} colors`}</Text>
</Row>
</Col>
))}
</Grid4>
</Col>
</Container>
</Section>
);
}

How it adapts

  • 1024px and up: four products per row.
  • Below 1024px: three per row, then two below 768px.
  • Each product is one link, and a sale price shows the old price struck through beside it.

How these props work is in responsive page sections without breakpoint classes.

Adapt it with your coding agent

Add the VaneUI MCP server, and your agent reads the component docs and prop tables while it changes the block: the copy, the sample data or the layout.

$ claude mcp add vaneui -- npx -y @vaneui/mcp

Setup for other editors is in the AI assistants guide.