← All Components
<mth-product-card>
E-commerce product card with sanitized media/link URLs, locale-aware currency pricing, accessible rating summary, and quick-add action.
When NOT to use: Use a lightweight @methane-ui/css layout class instead of a custom element when static CSS suffices.
Live Interactive Preview
Ready · interact with <mth-product-card>, or toggle Theme, Direction (LTR/RTL), or props above.
Multi-Framework Playground & Snippets
<script type="module" src="@methane-ui/commerce/product-card"></script>
<mth-product-card price="null" compare-at-price="null"></mth-product-card>import '@methane-ui/commerce/product-card';
import '@methane-ui/react';
export function Example() {
return <mth-product-card price="null" compare-at-price="null"></mth-product-card>;
}<script setup lang="ts">
import '@methane-ui/commerce/product-card';
</script>
<template>
<mth-product-card price="null" compare-at-price="null"></mth-product-card>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/commerce/product-card';
import { MthProductCardDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthProductCardDirective],
template: `<mth-product-card price="null" compare-at-price="null"></mth-product-card>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/commerce/product-card';
import MthProductCard from '@methane-ui/svelte/MthProductCard.svelte';
</script>
<MthProductCard price="null" compare-at-price="null"></MthProductCard>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
title | title | string | "" | Product display title. |
subtitle | subtitle | string | "" | Optional secondary product descriptor. |
imageSrc | image-src | string | "" | Product image URL validated via @methane-ui/sanitize isSafeUrl. |
imageAlt | image-alt | string | "" | Alternative text for product image. |
href | href | string | "" | Optional product detail link validated via isSafeUrl. |
price | price | number | null | null | Current unit price in currency. |
compareAtPrice | compare-at-price | number | null | null | Optional original strikethrough price. |
currency | currency | string | "USD" | ISO 4217 currency code. |
locale | locale | string | "" | Optional BCP 47 locale override for Intl.NumberFormat. |
badge | badge | string | "" | Optional promotional badge text. |
rating | rating | number | null | null | Optional numeric star rating (0–5). |
reviewCount | review-count | number | null | null | Optional total review count shown alongside rating. |
inStock | in-stock | boolean | true | Whether the product is purchasable. |
actionLabel | action-label | string | "" | Custom CTA label overriding localized Add to cart text. |
Events
| Event | Detail Type | Description |
|---|---|---|
mth-add-to-cart | { title: string; price: number | null; currency: string } | Fired when the user clicks the Add to cart button. |
mth-product-select | { title: string; href: string } | Fired when the user activates the product link/title. |
Accessibility Checklist
| Category | Requirement | Verified By |
|---|---|---|
| aria | All aria-* IDREFs resolve within the same DOM root (ADR-003). | scanSameRootAria |
| focus | delegatesFocus: true with zero host internals.role (ADR-014). | lint-plugin & spec-compiler |
| contrast | Renders legible borders, focus outlines, and selection indicators under forced-colors: active. | Playwright forced-colors matrix |
| states | Exposes ElementInternals CustomStateSet flags: :state(out-of-stock), :state(on-sale). | Conformance suite |
| i18n | Routes 5 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |