# Price

> Prices for a storefront in any currency and locale. Handles sales, ranges, unit prices, free items and prices that change with the variant.

Canonical: https://hextaui.com/blocks/price
Last updated: 2026-10-29

## Overview

Price is the one component every storefront block uses to show money. It takes a Money value, { amount: "48.00", currencyCode: "USD" }, and formats it with Intl for the shopper’s locale: $48.00 in the US, 48,00 € in Germany, ¥7,200 in Japan with no decimals, ₹4,000 with Indian grouping.

A compare-at price higher than the price shows struck through with the saving next to it, as a percentage or an amount. Screen readers hear “Sale price $36, Regular price $48” instead of two bare numbers. A range reads “From $28” on a product card or “$28 – $78” in full, and collapses to one price when both ends match. Zero reads Free, and a missing price reads Price unavailable or your own wording.

When the price changes, for example when a shopper picks a bigger size, only the digits that changed roll to their new value, with tabular figures so nothing around the price moves. Unit prices sit on their own line under the price.

The money helpers behind it, money, addMoney, multiplyMoney, sumMoney, fromMinorUnits and discountPercent, work in integer minor units so 0.1 + 0.2 is 0.30, and they refuse to add two currencies together. Cart, checkout and dashboard blocks use the same helpers.

## Installation

### Step 1: Get HextaUI Pro

One payment unlocks every block, including future ones. [See pricing](https://hextaui.com/pricing).

### Step 2: Add the Pro registry to components.json

```json title="components.json"
{
  "registries": {
    "@hextaui-pro": {
      "url": "https://hextaui.com/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${HEXTAUI_PRO_TOKEN}"
      }
    }
  }
}
```

### Step 3: Add your token

Create a token on your [account page](https://hextaui.com/account) and put it in `.env.local` as `HEXTAUI_PRO_TOKEN`.

### Step 4: Add the block

```bash
npx shadcn@latest add @hextaui-pro/price
```

## Usage

### From your product data

Pass the price and compare-at price as Money, the same { amount, currencyCode } shape Shopify’s Storefront API returns. A compare-at price that isn’t higher is ignored, so a data mistake never shows a fake sale.

```tsx
import { Price } from "@/components/blocks/price/price"
import type { Money } from "@/components/blocks/price/money"

type ProductPriceProps = {
  price: Money
  compareAtPrice: Money | null
}

export function ProductPrice({ price, compareAtPrice }: ProductPriceProps) {
  return (
    <Price
      size="lg"
      value={price}
      compareAt={compareAtPrice}
      locale="en-US"
      trailingZeros={false}
    />
  )
}
```

### From minor units

Stripe, Paddle and most payment APIs send integers in the currency’s smallest unit. fromMinorUnits turns 4800 USD into $48.00 and 4800 JPY into ¥4,800, because yen has no cents.

```tsx
import { fromMinorUnits } from "@/components/blocks/price/money"
import { Price } from "@/components/blocks/price/price"

type StripePrice = {
  unit_amount: number
  currency: string
}

export function PlanPrice({ price }: { price: StripePrice }) {
  return <Price value={fromMinorUnits(price.unit_amount, price.currency)} />
}
```

### Unit prices

Show the price per 100 mL or per kg under the price, as EU rules require for goods sold by volume or weight. The money helpers do the math in minor units, so totals never drift.

```tsx
import { fromMinorUnits, toMinorUnits, type Money } from "@/components/blocks/price/money"
import { Price } from "@/components/blocks/price/price"

export function RefillPrice({ price, milliliters }: { price: Money; milliliters: number }) {
  const per100 = fromMinorUnits(
    (toMinorUnits(price) * 100) / milliliters,
    price.currencyCode
  )
  return (
    <Price
      value={price}
      unitPrice={{ amount: per100, per: "100 mL" }}
      locale="de-DE"
    />
  )
}
```

## Anatomy

The parts you compose, from the outside in.

| Part | Description |
| --- | --- |
| `Price` | The current price, compare-at price, saving and unit price. |
| `PriceSkeleton` | A loading placeholder the size of a price. |
| `money, fromMinorUnits, toMinorUnits` | Build Money from major units, minor units or back. |
| `addMoney, subtractMoney, multiplyMoney, sumMoney, compareMoney` | Exact money math in minor units. Throws when currencies differ. |
| `formatMoney, discountPercent` | Format Money as text, and work out the saving as a whole percent. |

## API reference

### Price

Also takes span props.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `value` | `Money \| { min: Money; max: Money } \| null` | – | The price, or a range. null shows the unavailable label. |
| `compareAt` | `Money \| null` | – | The original price. Shown only when higher than value. |
| `unitPrice` | `{ amount: Money; per: string }` | – | A unit price line, such as $4.17 / 100 mL. |
| `saving` | `"percent" \| "amount" \| "none"` | `"percent"` | How to show the saving on a sale. |
| `range` | `"from" \| "span"` | `"from"` | Show a range as “From $28” or “$28 – $78”. |
| `size` | `"sm" \| "default" \| "lg" \| "xl"` | `"default"` | Text size. The compare-at price and saving scale with it. |
| `locale` | `Intl.LocalesArgument` | `"en-US"` | Locale for formatting. Fixed by default so server and browser render the same text. |
| `currencyDisplay` | `"symbol" \| "narrowSymbol" \| "code" \| "name"` | `"narrowSymbol"` | How to write the currency. |
| `trailingZeros` | `boolean` | `true` | Set false to show $48 instead of $48.00. Prices with cents keep them. |
| `animated` | `boolean` | `true` | Roll changed digits when the price changes. |
| `labels` | `Partial<PriceLabels>` | – | Words for sale, regular, from, free, unavailable, save and per. |

### Money

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `amount` | `string` | – | A decimal string in major units, like "48.00". |
| `currencyCode` | `string` | – | An ISO 4217 code, like "USD". |

## Accessibility

- Sale prices read with their meaning, “Sale price $36, Regular price $48, Save 25%”, and a range reads “$28 to $78”.
- Rolling digits are hidden from screen readers, which get the formatted price as plain text. With reduced motion, the price changes without rolling.
- Figures are tabular, so a changing price never shifts the layout around it.

## Built with

The free HextaUI components Price is made from. Each one installs on its own.

- [Number flow](https://hextaui.com/docs/number-flow) - Animated numbers where only the changed digits spin, with any Intl format and locale.
- [Skeleton](https://hextaui.com/docs/skeleton) - Placeholders that wait 150ms before showing, take the exact size of the content they wrap, and fade it in without moving anything.

## Code

4 files, added to components/blocks/price.
