ProductCard
A product in a shop's grid: its picture at a fixed ratio, the title, a subtitle, the price and the colours it comes in.
Sale
View code
<ProductCard
href={`/posters/${poster.slug}`}
title={poster.title}
subtitle={poster.artist}
media={<img src={poster.picture} alt="" />}
hoverMedia={<img src={poster.framed} alt="" />}
price={<Price amount={poster.price} compareAt={poster.compareAt} currency="USD" size="sm" />}
badges={poster.onSale ? <Badge>Sale</Badge> : undefined}
swatches={poster.frames}
action={<WishlistButton poster={poster} />}
/>Installation
An ordinary dependency: install it, import the theme once, and import the component where it is used.
npm add @sdxc/ui remiximport "@sdxc/ui/theme.css";Usage
import { ProductCard } from "@sdxc/ui/commerce";Renders the card. The title link's ::after fills the article, so a click anywhere opens
the product, and badges and action sit on a layer above it to stay reachable.
Props
Read from the component's own types, so every prop, every default and every allowed value is listed.
| Prop | Type | Required | Description |
|---|---|---|---|
href | string | Yes | The product's page; the title links there and the link covers the card. |
title | RemixNode | Yes | |
subtitle | RemixNode | No | A line under the title, such as the artist or the material. |
media | RemixNode | Yes | |
hoverMedia | RemixNode | No | A second picture the card crossfades to on hover and focus, such as the poster framed. |
mediaBackground | string | No | The colour behind the picture. |
ratio | string | No | The picture's aspect ratio. @default "4 / 5" |
price | RemixNode | Yes | The price, such as a Price. |
badges | RemixNode | No | Tags over the picture's top-start corner, such as "New" or "Sale". |
swatches | Swatch[] | No | The colours the product comes in; five dots show, then "+N". |
swatchesLabel | string | No | The swatch list's accessible name. @default "Colours" |
action | RemixNode | No | A control over the picture's top-end corner, such as a wishlist form; it stays clickable. |
headingLevel | 2 | 3 | 4 | No | The title's heading level. @default 3 |
Also accepts everything in Omit<TagProps<"article">, "children" | "title">.