NumberInput
The NumberInput component allows users to enter numeric values. It provides increment and decrement controls and supports formatting, limits, and steps.
Example Usage
Min, Max, and Step
You can constrain the input using min and max props.
The step prop determines the increment/decrement amount.
Formatting
Similar to TextInput, NumberInput supports formatOptions for currencies or percentages.
astro
<NumberInput
id='num-format'
label='Price'
value={100}
formatOptions={{ style: 'currency', currency: 'USD' }}
/> API
| Property | Description | Type | Default |
|---|---|---|---|
| label | Label text for the input | string | |
| min | Minimum value | number | |
| max | Maximum value | number | |
| step | Step value for increments/decrements | number | 1 |
| value | Current value | number | |
| formatOptions | Options for formatting the input value | Intl.NumberFormatOptions | |
| locale | Locale for formatting the input value | string | |
| error | Error message for the input | string | boolean |