Components

Input Price

new

A currency amount field that accepts digits and a capped decimal only.

$
USD
$
USD
Set a higher price to show a markdown at checkout.

Installation

npx shadcn@latest add @blank/input-price

Usage

import { InputPrice } from "@/components/ui/input-price"
<InputPrice code="USD" value={price} onValueChange={setPrice} />

Input Price is an InputGroup with the symbol and code as addons, so it sizes, focuses and shows errors exactly like every other field. Wrap it in Field for a label and a description.

The value stays a string. Keystrokes and pastes are cleaned as they land — commas are read as grouping, so a pasted 1,299.00 becomes 1299.00 — and the fraction is capped at precision digits. Parse it to a number, or to cents, where you submit.

Examples

Currencies

precision={0} accepts whole numbers only, for currencies without minor units.

€
EUR
¥
JPY
£