Price Tag

$29, per month, was $39, Save 26%
About this component

Price Tag

A price, formatted by the locale's own rules: cents hide on whole amounts, the currency symbol and cents can sit smaller and raised, and a short period follows the number. When the amount changes, as on a monthly to yearly switch, each digit rolls the way the price moved. An optional old price is struck through beside a computed "Save 20%" chip, a zero reads as "Free", and the whole price is spelled out for screen readers. Three tones for the chip and three sizes.

Usage

The import and the props worth knowing about, in one place.

import { PriceTag } from "@/components/beste/component/price-tag";

<PriceTag amount={29} period="/mo" periodLabel="per month" />

// A yearly switch: the digits roll to the new amount
<PriceTag amount={yearly ? 290 : 29} period={yearly ? "/yr" : "/mo"} />

<PriceTag
  amount={24}
  compareAt={30}        // struck through, with a "Save 20%" chip
  currency="EUR"
  locale="de-DE"
  symbol="raised"       // "inline" (default) | "raised"
  cents="raised"
  tone="outline"        // "muted" (default) | "outline" | "ghost"
  size="lg"             // "sm" | "default" | "lg"
/>

Props

Read from the component's own type, so this cannot drift from what it accepts.

PropTypeDefaultDescription
amount*number—The price, in major units (29.5 is $29.50).
currencystring—ISO 4217 code, e.g. "USD", "EUR".
localestring—Formatting locale; the reader's own when omitted.
fractionDigits"auto" | number—"auto" hides the cents on whole amounts; a number always shows that many.
periodstring—Short suffix after the amount, e.g. "/mo".
periodLabelstring—How the period is read aloud, e.g. "per month". Falls back to `period`.
compareAtnumber—The old price, struck through beside the current one.
showSavingsboolean—Show a "Save 20%" chip when `compareAt` is higher than `amount`.
savingsLabelstring—Template for the chip; `{percent}` is replaced by the saving.
freeLabelstring | null—Shown instead of the number when `amount` is 0. Pass null to print the zero.
symbol"inline" | "raised"—Currency symbol beside the digits, or smaller and raised.
cents"inline" | "raised"—Cents beside the digits, or smaller and raised.
tone"muted" | "outline" | "ghost"—
size"sm" | "default" | "lg"—
classNamestring—

More Price components

View all Price
$12, per month