SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

On this page

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

Dune at dusk

Ana Ortiz

$36.00Was $45.00Save 20%

  • Oak
  • Black
  • White

Low tide

Mo Rahman

From $29.00

  • Oak
  • Black
  • White
View code
tsx
<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.

Terminal
npm add @sdxc/ui remix
typescript
import "@sdxc/ui/theme.css";

Usage

typescript
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.

PropTypeRequiredDescription
hrefstringYesThe product's page; the title links there and the link covers the card.
titleRemixNodeYes
subtitleRemixNodeNoA line under the title, such as the artist or the material.
mediaRemixNodeYes
hoverMediaRemixNodeNoA second picture the card crossfades to on hover and focus, such as the poster framed.
mediaBackgroundstringNoThe colour behind the picture.
ratiostringNoThe picture's aspect ratio. @default "4 / 5"
priceRemixNodeYesThe price, such as a Price.
badgesRemixNodeNoTags over the picture's top-start corner, such as "New" or "Sale".
swatchesSwatch[]NoThe colours the product comes in; five dots show, then "+N".
swatchesLabelstringNoThe swatch list's accessible name. @default "Colours"
actionRemixNodeNoA control over the picture's top-end corner, such as a wishlist form; it stays clickable.
headingLevel2 | 3 | 4NoThe title's heading level. @default 3

Also accepts everything in Omit<TagProps<"article">, "children" | "title">.

@sdxc/ui

Can’t find it? Contact us