AmountInput
A specialized input component for handling numeric amounts with proper formatting.
AmountInput
The AmountInput component provides a specialized input field for handling numeric amounts with automatic formatting and validation.
Usage
Props
Prop | Type | Default | Description |
---|---|---|---|
type | string | - | Input type (usually "text") |
placeholder | string | - | Placeholder text |
value | string | "" | Controlled input value |
disabled | boolean | false | Whether the input is disabled |
icon | ReactNode | - | Optional icon element |
onChange | (value: string) => void | - | Called with formatted amount |
className | string | - | Additional CSS classes |
Features
- Automatic number formatting
- Prevents invalid number inputs
- Handles decimal points appropriately
- Optional icon support
- Controlled value management
- Background color inheritance
Examples
Basic Amount Input
With Maximum Value
With Currency Symbol
In a Form
Number Formatting
The component uses parseNumberInput
utility to:
- Allow only numeric input
- Handle decimal points
- Remove leading zeros
- Maintain proper number format
Edit on GitHub
Last updated on