Skip to content

OrderCard ​

A high-frequency card for order lists and order detail pages: the header pairs the order number with a status badge, followed by an item summary (image + name + spec × quantity), the amount area (paid / struck-through original / saved amount), an actions slot at the bottom, and an optional collapsible details region. Both the badge copy and its colour semantics are fully declared through status-map.

Basic usage ​

status is the status key and status-map maps keys to copy plus a semantic tone; items is the item summary and the actions slot holds the action buttons:

Pending order with actions

CancelPay now

Actions come from the host (the card dispatches no business events); see the details demo below.

Status semantics ​

status-map is { key: { label, tone } } and also accepts a plain string (equivalent to tone: 'default'). Five tones are available: default / primary / success / warning / danger. A status that is not mapped is shown as-is so hosts can adopt it gradually.

Five tones plus shorthand

Amount area ​

payable is the amount paid, original the pre-discount amount (rendered struck through, only alongside payable) and discount the saved amount; the whole amount area hides when both payable and discount are absent (setting only original renders no empty bar). currency / locale / precision are forwarded to the nested price component.

Paid + struck-through original + saved (USD / one decimal)

Collapsible details ​

expandable turns on the details toggle; the expanded region renders the details slot — when the slot is empty the toggle is not rendered at all (no blank panel). A user click writes the expanded attribute back and dispatches oas-toggle; hosts may also set expanded directly to preset the state (controlled, no event).

Collapsed / preset expanded / event feedback

Ordered: 2024-11-24 10:20Delivery: SF Express, free shipping · expected 11-26Recipient: Mr. Zhang · 138****0000
Track shipment
Ordered 2024-11-23 21:05 · dispatched

Click the details toggle to see oas-toggle feedback.

Empty items ​

When items is missing or empty the card renders "No items"; give it only amounts to use it as a lightweight bill card.

No items

Styling notes ​

::part(card) is a column flex: head → items → amount → details → foot. Inside ::part(foot) the toggle is pushed to the inline start by margin-inline-end: auto while the actions slot stays at the inline end; overriding justify-content on ::part(foot) affects both. The card itself is not clickable — wrap it in an <a> when the entire card should navigate.

API ​

oas-order-card ​

Attributes ​

AttributeDescriptionTypeDefault
currencyISO 4217 currency, default CNYstringCNY
discountSaved amount (non-negative number) shown with the i18n orderCard.discount copy——
expandableTurns on the details toggle (the toggle is not rendered when the details slot is empty)boolean—
expandedExpanded state: written back by the component after a user click; hosts may set it to preset the state (controlled, no oas-toggle)boolean—
itemsItem summary JSON array [{ image?, title, spec?, quantity? }]; entries without title are ignored and quantity defaults to 1OrderCardItem[] | string—
localeAmount formatting locale; defaults to the document <html lang>, then en——
order-idOrder number shown in the header (omitted leaves the slot empty)——
originalPre-discount amount rendered struck through (uses the nested oas-price original channel)——
payableAmount paid (non-negative number); when original and discount are absent too the whole amount area hides——
precisionAmount decimal places, default 2——
statusStatus key looked up in status-map; unmapped keys are shown as-is——
status-mapStatus semantics JSON object { key: { label, tone } }, or the shorthand { key: "copy" } (same as tone: default). Five tones: default / primary / success / warning / danger; invalid tones fall back to default and warn onceOrderStatusMap | string—

Property (JS property; see each row for attribute reflection) ​

PropertyDescriptionTypeDefault
itemsItem summary: get+set accessor (array or JSON string) reflecting the items attributeOrderCardItem[] | string—
statusMapStatus semantics: get+set accessor (object or JSON string) reflecting the status-map attributeOrderStatusMap | string—

Events ​

EventDescription
oas-toggleFired after a user toggles the details, detail: { expanded, orderId }; host-side expanded writes do not fire it

Slots ​

NameDescription
actionsAction buttons (pay, track shipment, buy again, …)
detailsCollapsible details content (order number, placed time, shipping info, …); no content means no toggle

Released under the MIT OR Apache-2.0 License.