ProductCard
A high-frequency card for product grids and recommendation slots: image (configurable ratio), two-line clamped title, price with an optional struck-through original, and three slots for tags, promo copy and actions. layout offers vertical (default) and horizontal forms.
Basic usage
image / title / price are the minimum set; original-price adds the struck-through price and the slots carry tags and buttons:
Vertical card with tags and an action
Image ratio
image-ratio sets the aspect ratio of the media box; 16:9, 4/3 and plain numbers (1.5) are accepted. The default is 1:1; an invalid value falls back to 1:1 and warns once in development.
1:1 (default) / 4:3 / 16:9
Price and currency
price is the current price and original-price the struck-through one (screen readers announce it as the original price); currency / locale / precision match oas-price:
USD / one decimal
Horizontal layout
layout="horizontal" moves the image to the inline start (fixed 104px wide, height by ratio) with the content at the inline end — handy for cart recommendations and order add-ons.
layout=horizontal
Promo copy and long titles
The promo slot carries promotional copy (discounts, flash-sale countdowns); titles are clamped at two lines while the full text stays in the DOM and in the title tooltip.
Promo copy + two-line clamp
Styling notes
The card is static content (not focusable, it never swallows clicks): wrap it in an <a> when the whole card should navigate, and use the actions slot for buttons. ::part(media) carries an inline aspect-ratio; when overriding its size remember object-fit: cover. actions uses margin-block-start: auto so buttons line up across cards with different title heights.
API
oas-product-card
Attributes
| Attribute | Description | Type | Default |
|---|---|---|---|
currency | ISO 4217 currency, default CNY | string | CNY |
image | Image URL (a failed load falls back to the dashed placeholder; changing image retries) | — | — |
image-ratio | Media aspect ratio: 16:9 / 4:3 / a plain number (1.5); defaults to 1:1, invalid values fall back to 1:1 and warn once | — | — |
layout | Card form: vertical (default, image on top) / horizontal (image at the inline start, fixed 104px wide); invalid values fall back to vertical and warn once | — | — |
locale | Amount formatting locale; defaults to the document <html lang>, then en | — | — |
original-price | Struck-through original price (uses the nested oas-price original channel) | — | — |
precision | Amount decimal places, default 2 | — | — |
price | Current price (non-negative number); when both this and original-price are absent the price area hides | — | — |
title | Product title (clamped to two lines; the full text stays in the DOM and tooltip, and doubles as the image alt) | — | — |
Slots
| Name | Description |
|---|---|
actions | Action buttons (add to cart, buy now, …) — collapses when empty |
promo | Promotional copy (discounts, flash-sale countdowns) — collapses when empty |
tags | Tag chips (discount, sold-by-us, free shipping, …) — collapses when empty |