A number field with − / + steppers, arrow-key steps, limits and locale formatting — and MoneyInput for amounts.
$ pnpm dlx shadcn@latest add https://dashral.com/r/number-input.jsonInstallation
$ pnpm dlx shadcn@latest add https://dashral.com/r/number-input.jsonAdds the component, the components it builds on, its npm packages and the theme tokens it uses. Using Dashral often? Add the registry to components.json once:
{
"registries": {
"@dashral": "https://dashral.com/r/{name}.json"
}
}Then add components by name:
$ pnpm dlx shadcn@latest add @dashral/number-inputUsage
import { NumberInput, MoneyInput } from "@/components/dashral/number-input"
<>
<NumberInput label="Seats" defaultValue={5} min={1} max={50} />
<MoneyInput label="Price" currency="USD" defaultValue={49} />
</>Examples
API reference
NumberInput
Also takes every prop of <input>(opens in a new tab).
| Prop | Type | Default |
|---|---|---|
value / defaultValue | number | nullControlled or initial; null when empty. | null |
onValueChange | (value: number | null) => voidOn blur or Enter, and on every step. | — |
min / max | numberLimits; values are clamped to them. | — |
step | numberArrow keys and buttons; ×10 with Shift or Page Up / Down. | 1 |
locale / formatOptions | string / Intl.NumberFormatOptionsFormatting when not editing, and how typing is read. | LocaleProvider's |
stepper | booleanThe − and + buttons. | true |
prefix / suffix | ReactNodeInside the field, e.g. a unit. | — |
label | ReactNodeShown above, linked to the control. | — |
description | ReactNodeA hint under the control. | — |
error | boolean | ReactNodetrue shows the error style; a message also shows under the control. | — |
labelAction | ReactNodeAt the end of the label's row, e.g. a “Forgot password?” link or the current value. | — |
withAsterisk | booleanMarks the label with an asterisk, e.g. alongside required. | false |
classNames | { root, label, description, error }Classes for each part. | — |
MoneyInput
NumberInput with the currency's symbol and decimals. Takes the same props.
| Prop | Type | Default |
|---|---|---|
currency | stringISO 4217 code, "USD", "IDR". Required. | — |
min | number | 0 |
step | number | 1 (1000 for currencies without decimals) |
Keyboard
| Keys | Action |
|---|---|
| ↑or↓ | Add or subtract one step |
| Shift+↑orShift+↓orPage UporPage Down | Ten steps |
| HomeorEnd | Jump to min / max (when set) |
| Enter | Commit what's typed |
Accessibility
- role="spinbutton" with aria-valuenow, min, max and the formatted value as text. The − / + buttons are labelled and left out of the tab order (the arrow keys do the same).