shadcn.io is not affiliated with official shadcn/ui
Input Group examples · Text
Currency Input Input Group for React
Dollar and euro amount inputs with the symbol before and the currency code after.
Money fields that say their currency twice, the symbol before the amount and the code after: $ … USD and € … EUR, each as InputGroupText in addons around the input.
Preview
Installation
FAQ
How do the symbol and the code sit on both sides?
The symbol's addon keeps the default inline-start; the code's has align="inline-end". Both come after the input.
How is the amount input set up?
type="text" with inputMode="decimal": a numeric keyboard with a decimal point, and no spinner arrows or rounding from type="number".
How are the inputs labeled?
aria-labels that include the currency: Amount in US dollars and Amount in euros.
How do I format the amount?
Parse and format on blur with Intl.NumberFormat for the currency, and store the number, not the string.
Can people change the currency?
Not here. Put a menu in the end addon, as in URL Builder with Dropdown.
Related
- URL Builder Input GroupA domain input between a fixed https://
- Email with Domain Input GroupA username input with a fixed @vercel.com
- Inline Labels Input GroupA username input after an @ label and a
- Currency InputAn amount field with a dollar sign inside
- Input with LabelA text input with a label above it
- Character Counter Input Group (Text)A tweet input with a 280-character limit