Product Card
ProA shop tile with an image, name, price and rating, plus an optional badge, wishlist heart and add-to-cart button. The image opens the product; the card itself is not a link.
Playground
Standing desk Pro
4.8 (312)
Standing desk Pro
4.8 (312)
Standing desk Pro
4.8 (312)
Standing desk Pro
4.8 (312)
Standing desk Pro
In stock
Standing desk Pro
In stock
Standing desk Pro
Currently unavailable
Standing desk Pro
Currently unavailable
Standing desk Pro
Standing desk Pro
Installation
Product Card comes with WunderUI Core and Pro, in the package from your plan. See the plans.
Then import what you need:
import { ProductCard, ProductCardProps, ProductMiniCard } from "@wunderui/react"Then use it:
import { ProductCard } from "@wunderui/react"
export function Product() {
return <ProductCard name="Standing desk Pro" price="$489.00" tint="indigo" className="w-60" />
}Expected result: You should see a 240 px wide tile with an indigo image area and a package icon, the name Standing desk Pro in medium text and the price $489.00 under it.
When to use
Use Product Card for
- A grid of products in a shop or a category page
- A wishlist or a row of recommended products
- A product with a sale price, a badge and a quick add to cart
Use something else for
- Product Mini Card for a compact row with a small image and a quick add button
- Item Card for one object with a description and its own action, without a price
- Card for a free container for any content, with a header, a body and a footer
Content
Only name and price are required. Pass either a rating with a review count (stars and the count) or availability, which replaces that line; an old price shows crossed out beside the price.
Standing desk Pro
Standing desk Pro
4.8 (1,842)
Standing desk Pro
In stock
Standing desk Pro
4.8 (312)
Badge
A badge sits on the top left of the image, red unless you pass a colour, with a label you choose such as Sale or New. A sold out product needs no badge of your own: it gets a grey Sold out badge.
Standing desk Pro
4.8 (312)
Standing desk Pro
4.8 (312)
Standing desk Pro
4.8 (312)
Standing desk Pro
4.8 (312)
Actions
A click handler puts a button over the image, a wishlist handler adds the heart and an add-to-cart handler adds the button under the text. Each is optional, and the name and price are not links.
Standing desk Pro
4.8 (312)
Standing desk Pro
4.8 (312)
Standing desk Pro
4.8 (312)
Standing desk Pro
4.8 (312)
Standing desk Pro
4.8 (312)
States
Wishlisted fills the heart. Sold out shows a grey badge, a red availability line and no add-to-cart button, and loading replaces the card with a skeleton of the same shape.
State
Standing desk Pro
4.8 (312)
Standing desk Pro
4.8 (312)
Standing desk Pro
4.8 (312)
Standing desk Pro
Currently unavailable
Image
Without an image the tile shows a tint and the package icon. With one, the photo fills the 7:4 area and loads lazily, and a broken address falls back to the tint and icon by itself.
Standing desk Pro
4.8 (312)
Standing desk Pro
4.8 (312)

Standing desk Pro
4.8 (312)
Long text
The name wraps onto more lines and the card grows, and the price row can wrap too in a very narrow card. Nothing is cut with an ellipsis.
Text
Standing desk Pro
4.8 (312)
Standing desk Pro with dual motors, memory presets and a solid oak top, 160 × 80 cm
4.8 (312)
Standing desk Pro with dual motors, memory presets and a solid oak top, 160 × 80 cm
4.8 (312)
Width
The card fills its container and the image keeps its 7:4 ratio, growing with the card. Give the card a width, or put it in a grid column.
Standing desk Pro
4.8 (312)
Standing desk Pro
4.8 (312)
Standing desk Pro
4.8 (312)
Compact
size="compact" turns the tile into a bordered row with a 48 px thumbnail, the name, the price and a round quick-add button (onAddToCart), for recommendations and cross-sells. The compact row shows the name, price, image, tint and the two handlers only. It replaces ProductMiniCard.
Keyboard interactions
A card has up to three tab stops, in order: the open button over the image, the wishlist heart and the add-to-cart button. Each exists only when its handler is set.
- TaborShift+Tab
- Moves focus to the next or previous control: open, wishlist, add to cart, then the next card.
- EnterorSpace
- Presses the focused button and calls , or .
Behavior and motion
What the card does with state, content, the DOM and motion.
- Three controls in one card
- A click handler adds a transparent button over the image, a wishlist handler adds the heart and an add-to-cart handler adds the button. They are siblings, and only the image opens the product.
- Content lines
- The price always shows. The last line is availability when sold out or set, otherwise the rating with its review count (ratings are clamped to 0 to 5), otherwise nothing.
- Wishlist
- A wishlisted card fills the heart and sets aria-pressed, and the button keeps one name, Wishlist, so the label never flips between Add and Remove. The card does not keep the state.
- Sold out and loading
- Sold out draws a grey badge, shows availability in the error colour and drops the add-to-cart button. Loading swaps the card for a skeleton and marks it busy; there is no hover or disabled look.
- Image and errors
- The image is cropped to 7:4 and has an empty alt text, since the name sits under it. With no image or a broken address, the area falls back to the tint and a package icon.
- Long text and width
- The card fills its container and the image keeps its ratio. The name and price row wrap, and nothing is cut with an ellipsis, so a card with a long name is taller than its neighbours.
- Focus
- The heart, the add-to-cart button and the image button show the standard focus ring. The image button's ring follows the 16 px corners.
- Motion and reduced motion
- The card does not animate. The buttons change colour on hover and press, which is not movement and stays the same under reduced motion.
Anatomy
The parts of a product card, numbered in the figure. The image, badge, heart, text and button are all parts of one component, shown here with every optional part.
Standing desk Pro
4.8 (312)
- 1data-slot="product-card"
Stacks the image, the text and the button with 12 px between them. It has no border or background, fills the width it is given, and is not a link or button itself.
- 2data-slot="product-image"
A Product Image with a 7:4 ratio and a 16 px radius, showing the photo or a tint with an icon when there is none. With a click handler, a transparent button named after the product covers it.
- 3Optional
A pill on the top left of the image, 12 px from the edges, red unless you set another colour. When sold out it becomes a grey Sold out pill and replaces the badge.
- 4Optional
A 32 px round icon button on the top right of the image, shown when a wishlist handler is set. The heart fills in the error colour while wishlisted.
- 5
The name in 14 px medium text. It wraps onto more lines when it is long.
- 6
A small Price with the price and, if set, the old price crossed out beside it.
- 7Optional
One line of 11 px text: when sold out, availability in the error colour (Currently unavailable by default); else availability in the success colour; else the Stars, rating and count.
- 8Optional
A full-width dark button, 32 px high, shown when an add-to-cart handler is set but not while sold out. Its text is the add-to-cart label.
- Optional
Best practices
- Do
Pass a click handler to open the product from the image, and make the name a link yourself if the product has its own page. The card is not a link, so call your router in the handler.
- Do
Keep the wishlist in your own state. The wishlisted value and its handler are controlled, so the card does not change the heart by itself.
- Do
Mark a product that cannot be bought as sold out: the card shows a grey badge and a red availability line and drops the add-to-cart button. Say when it is back, such as Back in stock Dec 4.
- Do
When a page holds many cards, put the product name in the add-to-cart label as hidden text. Otherwise every button reads the same.
- Do
Place the cards in a grid with a minimum column width, such as 10 rem, so image and text stay readable on a narrow screen.
- Do
Pass loading while products load. Each card becomes a skeleton of the same shape, so the grid does not jump, and name and price are not needed.
- Don’t
Don't pass a rating and availability together. Availability replaces the rating line, so the rating is not shown.
- Don’t
Don't pass a non-text name together with a click handler. The image button takes its label from the name only when it is a string, otherwise it reads Open product.
- Don’t
Don't format the review count yourself. The card writes it with an English thousands separator, so pass the number 1842 and it reads (1,842).
API reference
Product Card takes the props below and no other attributes, so an id, a data attribute or an aria-label cannot be passed to the card.
Stacks the image, the text and the button with 12 px between them. It has no border or background, fills the width it is given, and is not a link or button itself.
| Prop | Type | Default | Description |
|---|---|---|---|
| name | ReactNode | — | The product name, under the image. Also the label of the button over the image when it is a string. Required unless the card is . |
| price | ReactNode | — | The price, a finished string such as . Required unless the card is . |
| compareAt | ReactNode | — | The old price, crossed out beside the price. |
| rating | number | — | The rating. Draws the Stars and the number with one decimal. Not shown when is set. |
| reviews | number | — | The number of reviews, printed in brackets after the rating with a thousands separator in English, such as (1,842). Used only together with . |
| availability | ReactNode | — | A line that replaces the rating, in the success colour, for example . With it is the red line and defaults to . |
| badge | { label: ReactNode; color?: BadgeColor } | — | A pill on the image: . The colour is red by default. |
| image | string | — | The address of the product photo. Without it the image area shows the tint and an icon. |
| tint | "indigo" | "blue" | "purple" | "pink" | "red" | "orange" | "yellow" | "green" | "alternative" | — | The tint of the placeholder: indigo, blue, purple, pink, red, orange, yellow, green or alternative. Indigo by default. Not used with . |
| wishlisted | boolean | — | Fills the heart and sets . Controlled: the card does not change it. |
| onWishlist | () => void | — | Adds the heart button and is called when it is pressed. |
| onAddToCart | () => void | — | Adds the add-to-cart button and is called when it is pressed. Leave it out for a product without a quick add. A card never shows the button. |
| addToCartLabel | ReactNode | "Add to cart" | The text of the add-to-cart button. by default. |
| soldOut | boolean | — | Marks the product as sold out: a grey Sold out badge replaces , the availability line turns red (, by default) and the add-to-cart button is not drawn, also when is set. |
| loading | boolean | — | Shows a skeleton of the card in place of its content: is set and a visually hidden Loading product is added. and are not needed then. |
| onClick | () => void | — | Puts a button over the image and is called when it is pressed. Open the product in the handler. |
| className | string | — | Added to the card. Use it for the width. |
| size | "default" | "compact" | "default" | is the shop tile. is a bordered row with a 48 px thumbnail, the name, the price and a round quick-add button (), for recommendations and cross-sells. A compact card shows , , , , and only, and its placeholder is yellow unless you set . It replaces ProductMiniCard. |
| Prop | Type | Default | Description |
|---|---|---|---|
| name required | ReactNode | — | |
| price required | ReactNode | — | |
| image | string | — | |
| onAdd | () => void | — | |
| onClick | () => void | — | |
| tint | "indigo" | "blue" | "purple" | "pink" | "red" | "orange" | "yellow" | "green" | "alternative" | "yellow" |
Notes for AI
Give your coding assistant the Markdown reference instead of screenshots.
get_component("product-card")The full library index for assistants is at /llms.txt.