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
amountis the price.wasis the price before the sale. If it is higher thanamount, 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.
unitPriceandunitadd a line such as "$9.00 / kg". This helps buyers compare packs of different sizes.sizeissm,md(default), orlg.currencyis an ISO 4217 code (defaultUSD), andlocalesets the format.- Change the words with
labelsor a label pack: the functionsoff,sale, andper.
Usage
ts
import { BlessPrice } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
amount* | number | — | |
was | number | — | the price before the sale; it shows only when it is higher than `amount` |
unitPrice | number | — | the price for one unit, with `unit` |
unit | string | — | the unit, for example "kg" or "100 ml" |
currency | string | "USD" | |
locale | string | "en" | |
size | "md" | "sm" | "lg" | "md" | |
labels | Partial<{ off: (percent: string) => string; sale: (now: string, was: string) => string; per: (price: string, unit: string) => string; }> | — |