Price for Astro
Astro parts for amounts, currency labels, and billing periods.
Installation
bunx --bun shadcn@latest add @gnostic/pricenpx shadcn@latest add @gnostic/pricepnpm dlx shadcn@latest add @gnostic/priceCopy the files
src/components/ui/price/format-price-value.tssrc/components/ui/price/index.tssrc/components/ui/price/price-unit.astrosrc/components/ui/price/price-value.astrosrc/components/ui/price/price.astro
Usage
import { Price, PriceUnit, PriceValue } from "@/components/ui/price"
<Price>
<PriceValue price={99} />
<PriceUnit>month</PriceUnit>
</Price>
Examples
Notes
- Use
compareAtto show the original price and automatic savings output. - Pass
currencyandlocalewhen the defaultUSDanden-USformatting are not correct for your project. - Use
showDiscount={false}when you want the strike-through price without the savings badge.
API Reference
Read the installed source for the complete prop types.
When to use Price
Use Price to arrange the amount and its context in a pricing card or product summary. Keep currency, billing interval, and any conditions close to the number. Supply already formatted content through the parts.
Keyboard and behavior
Price displays text; it does not convert currencies, calculate tax, or process payment. Make a discounted price understandable in the reading order and explain whether an amount recurs.
Theme and layout
Typography can emphasize the amount while keeping its unit readable. Test long localized amounts and currency symbols. Use theme text tokens so the smaller billing text remains legible.