Product Detail with Variants
A single-image product hero focused on variant selection: color swatches, a size button group, a real plus/minus quantity stepper, and a heart wishlist toggle, above an Add to cart button. A simpler companion to the gallery variant, for products that only need one photo.
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-with-variants.jsonPrefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/ecommerce/ecommerce34.tsx instead.
Usage
The file also exports ecommerce34Demo, 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 { Ecommerce34, ecommerce34Demo } from "@/components/blocks/ecommerce/ecommerce34"; export default function Page() { return <Ecommerce34 {...ecommerce34Demo} />; }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| productName | string | none | Product title rendered as the page heading. |
| price | string | none | Pre-formatted price, e.g. "$68.00". |
| description | string | none | Product description paragraph. |
| image | MediaSlotImage | none | Product photo; falls back to a centered placeholder icon when omitted. |
| colors | ColorOption[] | [] | Color swatches rendered as a radio group; hidden entirely when empty. |
| sizes | string[] | [] | Size labels rendered as a button-style radio group; hidden entirely when empty. |
| className | string | none | Extra classes for the outer section element. |
Types
type MediaSlotImage = { src: string; alt: string }; type ColorOption = { name: string; hex: string };
Behavior notes
- Color/size selection, the quantity stepper, and the wishlist heart are all real client-side state (useState); Add to cart is decorative since there is no cart to add to in this standalone block.
- The quantity stepper clamps between 1 and 99 and disables the minus button at 1; the current count is announced to assistive tech via aria-live on the count itself.
- The wishlist button toggles a filled/unfilled heart and its aria-pressed state, but nothing is persisted or sent anywhere.
- The color swatches are native <input type="radio"> elements visually hidden with sr-only and reskinned via the wrapping <label>, using has-[:checked]/has-[:focus-visible] so keyboard focus is still visible.
More Ecommerce Blocks
View all →wishlist-manager
Wishlist Manager
Saved-items list with stock-status badges, move-to-cart and remove actions, and a real empty state.
product-information-tabs
Product Information Tabs
Tabbed product details with Description, Features, Specifications, Reviews, and Shipping panels.
collection-showcase-grid
Collection Showcase Grid
A large featured-collection hero card alongside a grid of smaller supporting collection tiles.
shop-by-brand-grid
Shop by Brand Grid
A grid of bordered brand tiles with a wordmark-style name, product count, and a hover affordance.
sale-countdown-timer
Sale Countdown Timer
A live days/hours/minutes/seconds countdown in default, compact, or full-width banner layouts.
gift-card-redemption-form
Gift Card Redemption Form
A code-entry form that validates against a fixed list of demo gift cards and shows a real success or error state.