Staaarter

Product Detail Page

A complete product detail section: a large main image with a row of clickable thumbnails that swap it, color swatches and a size button group, a price with an optional strikethrough original price, and an add-to-cart button. Built as the main content of a product page.

By Staaarter Team
Ecommerce
Docs
Live preview

Docs

Installation

A real shadcn registry command, not a copy-paste stand-in: it fetches this block plus its button, media-slot dependencies and any missing npm packages, and installs them straight into your project.

npx shadcn add https://staaarter.com/r/product-detail-page.json

Prefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/ecommerce/ecommerce19.tsx instead.

Usage

The file also exports ecommerce19Demo, the exact props behind the preview above. Spread it to get a working section in one line, then replace it with your own data.

import { Ecommerce19, ecommerce19Demo } from "@/components/blocks/ecommerce/ecommerce19";

export default function Page() {
  return <Ecommerce19 {...ecommerce19Demo} />;
}

Props

PropTypeDefaultDescription
imagesMediaSlotImage[]noneGallery images; the first is shown as the main image on load.
namestringnoneProduct name, rendered as the page's h1.
ratingnumberundefined0-5 rating; rounded to the nearest whole star for the filled-star count. Omit to hide the rating row entirely.
reviewCountnumberundefinedReview count shown next to the rating.
pricestringnonePre-formatted current price, e.g. "$89.00".
originalPricestringundefinedPre-formatted strikethrough price, shown only when set.
descriptionstringnoneProduct description paragraph.
colorsColorOption[][]Color swatches; hidden entirely when empty.
sizesstring[][]Size options rendered as a button group; hidden entirely when empty.
classNamestringnoneExtra classes for the outer section element.

Types

type MediaSlotImage = { src: string; alt: string };

type ColorOption = {
  name: string;
  hex: string; // literal CSS color, since these are real product swatches rather than a UI accent
};

Behavior notes

  • The thumbnail row is real client state: clicking a thumbnail swaps the large main image via a plain useState index, it isn't a carousel or slideshow.
  • Color swatches are real native radio inputs (visually hidden, driven by useState) and the size list is a real controlled button group, so selecting either updates the on-screen "Color: ..." / "Size: ..." label live. Neither selection changes the displayed price in this demo, since there's no variant-pricing backend to look up against.
  • "Add to cart" has no click handler; there's no cart to add to.
  • colors and sizes each render nothing at all when their array is empty, rather than an empty fieldset.