# NumberInput (@limerdev/zest) A number field: `` with `bind:value` (a number, or `null` when empty). It shows and reads numbers in the `locale`'s way (`sv-SE` writes 1 234,5) with `formatOptions` (`Intl.NumberFormat`: currency, percent, decimals), keeps the value within `min` and `max`, and steps by `step` with the arrow keys and its buttons, by `largeStep` with Page Up and Page Down, and to `min` and `max` with Home and End. It is a WAI-ARIA spinbutton. With `name`, the form posts the plain number. Inside a `Field` it takes its id, label, description, error and invalid and disabled state from the Field. - Category: Data input - Import: `import { NumberInput } from '@limerdev/zest'` - Exports: `NumberInput` - Use for: Amounts, prices, quantities, hours, percentages: any number people type or nudge. - Don't: Numbers that aren't amounts, such as phone numbers, postcodes or card numbers: use `Input` (with `inputmode="numeric"`). A value chosen on a scale: use `Slider`. A one-time code: use `PinInput`. ```svelte Amount ``` Props of `NumberInput`: - `decrementLabel` (`string`, default `the Config's `strings.decrease`, else 'Decrease'`): The decrease button's accessible name. - `formatOptions` (`NumberFormatOptions`, default `undefined`): How the number is shown: `Intl.NumberFormat` options, such as `{ style: 'currency', currency: 'SEK' }` or `{ maximumFractionDigits: 2 }`. - `incrementLabel` (`string`, default `the Config's `strings.increase`, else 'Increase'`): The increase button's accessible name. - `largeStep` (`number`, default `undefined`): How much Page Up and Page Down change the value. - `locale` (`string`, default `the Config's `defaultLocale`, else the browser's`): The locale that formats and parses the number (`sv-SE` writes 1 234,5). Set it in a server-rendered app, so the server and the browser agree. - `max` (`number`, default `undefined`): The largest value; typed values above it are lowered to it, and End goes to it. - `min` (`number`, default `undefined`): The smallest value; typed values below it are raised to it, and Home goes to it. - `step` (`number`, default `1`): How much an arrow key or a stepper button changes the value. - `steppers` (`boolean`, default `true`): Shows the increase and decrease buttons. - `value` (`number | null`, default `null`, bindable): The number, or `null` when the field is empty. Bindable. Example: Amount An amount in kronor: typed and shown the Swedish way, posted as a plain number. ```svelte Amount Without VAT. The value is {amount ?? 'empty'}. ``` Example: Formats formatOptions takes Intl.NumberFormat options: a whole quantity, hours with one decimal, a percentage. ```svelte
Seats Hours Discount
``` Example: States Without steppers, invalid in its Field, and disabled. ```svelte
Invoice number Hourly rate Enter a rate. Rounding
```