CurrencyInput
Money amount with the currency symbol, locale grouping (12,00,000 in en-IN), and an attached currency code.
Code
import * as React from 'react';
import { CurrencyInput } from '@fruit-labs/design';
export default function Demo() {
return (
<div
style={{
display: 'flex',
gap: 16,
maxWidth: 560,
}}
>
<CurrencyInput label="Annual CTC" currency="INR" locale="en-IN" defaultValue={1200000} />
<CurrencyInput label="Price" currency="USD" locale="en-US" decimals={2} defaultValue={49} />
</div>
);
}Install
From npm:
npm install @fruit-labs/design
import { CurrencyInput } from '@fruit-labs/design';Or copy the TypeScript source into your project:
npx shadcn@latest add https://design.fruitlabs.online/r/currency-input.jsonGuidelines
- Value is a number (or null). Shows raw digits while editing, formatted on blur.
- Use for salary/CTC, prices and budgets; set
currencyandlocale.
Props
| Prop | Type | Required |
|---|---|---|
value | number | null | No |
defaultValue | number | null | No |
onChange | (value: number | string | null) => void | No |
currency | string | No |
locale | string | No |
decimals | number | No |
showCode | boolean | No |
label | string | No |
hint | React.ReactNode | No |
error | React.ReactNode | No |
required | boolean | No |
placeholder | string | No |
size | 'sm' | 'md' | 'lg' | No |
className | string | No |
style | React.CSSProperties | No |