Skip to content
Calm motion: animations on this site only fade, with no movement

Price ​

A price with the old price, the discount, and a unit price

Shows a price in a shop, in the format of the locale. On a sale, it shows the old price struck through and the percent off. The product card uses it.

Basic
Rp 1.299.000Now Rp 899.000, was Rp 1.299.000, 31% offNow $4.20, was $5.00, 16% off$16.80 / kg$2.50$0.50 / 100 ml
  • amount is the price.
  • was is the price before the sale. If it is higher than amount, the old price and a tag such as "25% off" show.
  • Screen readers hear one sentence for a sale, such as "Now $75.00, was $100.00, 25% off". A struck-through number alone does not say that it is the old price.
  • unitPrice and unit add a line such as "$9.00 / kg". This helps buyers compare packs of different sizes.
  • size is sm, md (default), or lg.
  • currency is an ISO 4217 code (default USD), and locale sets the format.
  • Change the words with labels or a label pack: the functions off, sale, and per.

Usage ​

ts
import { BlessPrice } from "blessing-ui";

API ​

Props

NameTypeDefaultDescription
amount*number—
wasnumber—the price before the sale; it shows only when it is higher than `amount`
unitPricenumber—the price for one unit, with `unit`
unitstring—the unit, for example "kg" or "100 ml"
currencystring"USD"
localestring"en"
size"md" | "sm" | "lg""md"
labelsPartial<{ off: (percent: string) => string; sale: (now: string, was: string) => string; per: (price: string, unit: string) => string; }>—

Released under the MIT License. Character names and artwork belong to their owners.