Skip to content

Price ​

Price display with currency symbol, thousands separators and configurable decimals, plus original price (original), price range (min + max) and trend arrows (trend + trend-value). Formatting uses Intl.NumberFormat, and the symbol/number order follows the real Intl part order (so locales such as de-DE that place the symbol after the number work correctly).

Basic usage ​

value is a numeric string and currency is an ISO 4217 code (default CNY); original renders a struck-through original price.

Single value + original price

Currency and locale ​

locale defaults to the document <html lang> and can be overridden; precision controls decimals (0 hides them).

Currencies / locales

Price range ​

With both min and max present and no value, a range is rendered (single value wins):

Range

Trend ​

trend="up" / trend="down" renders a directional arrow and semantic color; numeric trend-value gets a sign and %, other text renders as-is. Up defaults to the danger color and down to success (Chinese market convention), both overridable via CSS variables.

Trend

Size ​

size="sm|md|lg" switches the three-level type scale (default md):

Sizes

API ​

oas-price ​

Attributes ​

AttributeDescriptionTypeDefault
currencyISO 4217 currency code, default CNY; invalid codes fall back to the default——
localeIntl.NumberFormat locale; defaults to the document <html lang>, then en——
maxRange upper bound (effective with min when value is absent)——
minRange lower bound (effective with max when value is absent)——
originalStruck-through original price (rendered as <s> with an "Original price" screen-reader prefix)——
precisionDecimal places (integer 0–20, default 2; invalid values fall back)——
sizeSize step: sm / md (default) / lgPriceSize—
trendTrend direction: up / down; invalid values render no trend——
trend-valueChange text (numeric values get a sign and %, other text renders as-is)——
valueSingle price (numeric string); wins over min + max when both are present——

CSS Variables ​

CSS VariableDefault
--oas-price-colorvar(--oas-color-text-primary)
--oas-price-down-colorvar(--oas-color-success-text)
--oas-price-original-colorvar(--oas-color-text-secondary)
--oas-price-up-colorvar(--oas-color-danger-text)

Released under the MIT OR Apache-2.0 License.