← All Components
<mth-cart>
Accessible shopping cart line-item list with quantity adjustments, item removal, URL sanitization, and localized currency breakdown.
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-cart>, or toggle Theme, Direction (LTR/RTL), or props above.
Multi-Framework Playground & Snippets
<script type="module" src="@methane-ui/commerce/cart"></script>
<mth-cart currency="USD" tax-rate="0"></mth-cart>import '@methane-ui/commerce/cart';
import '@methane-ui/react';
export function Example() {
return <mth-cart currency="USD" tax-rate="0"></mth-cart>;
}<script setup lang="ts">
import '@methane-ui/commerce/cart';
</script>
<template>
<mth-cart currency="USD" tax-rate="0"></mth-cart>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/commerce/cart';
import { MthCartDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthCartDirective],
template: `<mth-cart currency="USD" tax-rate="0"></mth-cart>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/commerce/cart';
import MthCart from '@methane-ui/svelte/MthCart.svelte';
</script>
<MthCart currency="USD" tax-rate="0"></MthCart>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
items | — | ReadonlyArray<unknown> | — | Array of CartItem entries in the cart. |
currency | currency | string | "USD" | ISO 4217 currency code used by Intl.NumberFormat. |
locale | locale | string | "" | Optional BCP 47 locale override; defaults to UIElement resolvedLocale. |
taxRate | tax-rate | number | 0 | Fractional tax rate applied to discounted subtotal (e.g., 0.08). |
shippingAmount | shipping-amount | number | 0 | Flat shipping amount added to total. |
discountAmount | discount-amount | number | 0 | Flat discount subtracted from subtotal before tax. |
allowRemove | allow-remove | boolean | true | Shows item removal controls when true. |
disabled | disabled | boolean | false | Disables interactive quantity, remove, and checkout actions. |
checkoutLabel | checkout-label | string | "" | Overrides localized checkout CTA label. |
Events
| Event | Detail Type | Description |
|---|---|---|
mth-quantity-change | { id: string; quantity: number } | Emitted event mth-quantity-change. |
mth-remove-item | { id: string } | Emitted event mth-remove-item. |
mth-checkout | { items: ReadonlyArray<unknown>; subtotal: number; total: number } | Emitted event mth-checkout. |
Accessibility Checklist
| Category | Requirement | Verified By |
|---|---|---|
| aria | All aria-* IDREFs resolve within the same DOM root (ADR-003). | scanSameRootAria |
| focus | Focus ownership matches focusModel="none". | 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(empty), :state(disabled). | Conformance suite |
| i18n | Routes 13 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |