Skip to content

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

20% offSold by usAdd to cartFree shippingView details

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

PromoSave 50 over 300Add to cartBuy again

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

Flash sale at 20:00

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 ​

AttributeDescriptionTypeDefault
currencyISO 4217 currency, default CNYstringCNY
imageImage URL (a failed load falls back to the dashed placeholder; changing image retries)——
image-ratioMedia 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——
layoutCard form: vertical (default, image on top) / horizontal (image at the inline start, fixed 104px wide); invalid values fall back to vertical and warn once——
localeAmount formatting locale; defaults to the document <html lang>, then en——
original-priceStruck-through original price (uses the nested oas-price original channel)——
precisionAmount decimal places, default 2——
priceCurrent price (non-negative number); when both this and original-price are absent the price area hides——
titleProduct title (clamped to two lines; the full text stays in the DOM and tooltip, and doubles as the image alt)——

Slots ​

NameDescription
actionsAction buttons (add to cart, buy now, …) — collapses when empty
promoPromotional copy (discounts, flash-sale countdowns) — collapses when empty
tagsTag chips (discount, sold-by-us, free shipping, …) — collapses when empty

Released under the MIT OR Apache-2.0 License.