ProductCard

A product with a gallery worth using: the picture follows your pointer and zooms, slides the way you move through the set, and the add button confirms when the add has happened. Cards.

Open playground
Sample notebook, view 1
-20%

Sample notebook

$30$24
128 reviews

Example product details. The picture follows your pointer; the arrow keys step through the set.

About

ProductCard is a React component in the Cards category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { ProductCard } from "@ashutoshswamy/smoui" and set badge, rating, onWishlist among its 9 props.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { ProductCard } from "@ashutoshswamy/smoui";

<ProductCard name="Notebook" price="$24" images={[{ src: "/front.jpg", alt: "Notebook front" }, { src: "/back.jpg", alt: "Notebook back" }]} onAction={() => addToCart()} />

Props 9

badge / compareAt

A tag over the picture and a struck-through earlier price.

string
rating / reviews

A star row under the name.

number
onWishlist

Adds a heart button.

(on: boolean) => void
onAction

A promise shows a busy state, then confirms.

() => void | Promise
onFilter

Makes each row a button that filters to that level.

(stars: number | null) => void
name / price

Product title and formatted price.

string
images

Gallery images with descriptive alt text.

{ src: string; alt: string }[]
description

Optional supporting detail.

string
onAction / actionLabel

Optional action button and its label.

() => void / string