All blocks
[36] E-commerce
Product Page
A gallery with thumbnails beside the price, color and size choices, quantity and an Add to cart button.
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. It passes an onClick handler, so in the Next.js App Router add "use client" at the top of its file.
product-page.tsx
import { useState } from "react";import { Breadcrumb, BreadcrumbItem, Button, Card, Col, Container, Grid4, Label, Link, List, ListItem, PageTitle, Radio, RadioGroup, Row, Section, SegmentedControl, SegmentedControlItem, Select, Text } from "@vaneui/ui";
const views = [ { label: "Front", tone: { warning: true } }, { label: "Back", tone: { warning: true } }, { label: "Detail", tone: { secondary: true } }, { label: "On a model", tone: { info: true } },];const colors = [ { value: "sand", label: "Sand", hex: "#d8c7a8" }, { value: "black", label: "Black", hex: "#1f2328" }, { value: "sage", label: "Sage", hex: "#a3b18a" },];const sizes = ["XS", "S", "M", "L", "XL"];const soldOut = ["XS"];
function Tee({ size }: { size: number }) { return ( <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.25" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"> <path d="M8 3 3 6l2 5 3-1v11h8V10l3 1 2-5-5-3a4 4 0 0 1-8 0z" /> </svg> );}
export function ProductPage() { const [view, setView] = useState(0); const [color, setColor] = useState("sand");
return ( <Section> <Container itemsStretch> <Col lg> <Breadcrumb> <BreadcrumbItem href="/shop">Shop</BreadcrumbItem> <BreadcrumbItem href="/shop/clothing">Clothing</BreadcrumbItem> <BreadcrumbItem>Everyday tee</BreadcrumbItem> </Breadcrumb> <Row tabletStack itemsStart xl> <Col flex1 wFull className="min-w-0 max-w-xl"> <Card {...views[view].tone} aspectSquare itemsCenter justifyCenter role="img" aria-label={`Everyday tee, ${views[view].label.toLowerCase()} view`}> <Tee size={160} /> </Card> <Grid4 sm className="max-tablet:grid-cols-4 max-mobile:grid-cols-4"> {views.map((v, i) => ( <Card key={v.label} tag="button" type="button" {...v.tone} aspectSquare itemsCenter justifyCenter cursorPointer focusVisible strongBorder={i === view} aria-pressed={i === view} aria-label={`Show the ${v.label.toLowerCase()} view`} onClick={() => setView(i)}> <Tee size={32} /> </Card> ))} </Grid4> </Col> <Col tag="form" lg flex1 wFull className="min-w-0" onSubmit={(e) => e.preventDefault()}> <Col sm> <PageTitle>Everyday tee</PageTitle> <Row flexWrap itemsBaseline> <Text xl fontSemibold className="tabular-nums">$32.00</Text> <Text sm secondary>4.8 out of 5, <Link href="#reviews">126 reviews</Link></Text> </Row> <Text secondary>A heavy cotton tee with a relaxed fit that keeps its shape wash after wash.</Text> </Col> <Col sm> <Text sm fontMedium id="color-label">Color: {colors.find((c) => c.value === color)?.label}</Text> <RadioGroup name="color" value={color} onChange={(e) => setColor(e.target.value)} aria-labelledby="color-label" row flexWrap> {colors.map((c) => ( <Label key={c.value} row itemsCenter> <Radio value={c.value} /> <svg width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"> <circle cx="12" cy="12" r="10" fill={c.hex} stroke="currentColor" strokeOpacity="0.3" strokeWidth="2" /> </svg> {c.label} </Label> ))} </RadioGroup> </Col> <Col sm> <Row justifyBetween> <Text sm fontMedium id="size-label">Size</Text> <Link href="/size-guide" sm>Size guide</Link> </Row> <SegmentedControl name="size" defaultValue="M" aria-labelledby="size-label" wFull> {sizes.map((s) => ( <SegmentedControlItem key={s} value={s} disabled={soldOut.includes(s)}>{s}</SegmentedControlItem> ))} </SegmentedControl> <Text xs tertiary>XS is sold out. More arrive on Dec 20.</Text> </Col> <Row> <Select name="quantity" aria-label="Quantity" defaultValue="1" md wFit noShrink> {[1, 2, 3, 4, 5].map((n) => <option key={n} value={n}>{n}</option>)} </Select> <Button type="submit" filled md flex1>Add to cart</Button> </Row> <List sm> <ListItem>100% organic cotton, 220 g/m²</ListItem> <ListItem>Pre-washed, so it keeps its size</ListItem> <ListItem>Free shipping over $50 and free returns</ListItem> </List> </Col> </Row> </Col> </Container> </Section> );}Components in this block
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.