Number input
number , or null when empty.
vig-number-input
import { NumberInput } from '@vigdx/ui/number-input';Basic
[(value)] to a number | null signal. The value commits on blur or Enter and is clamped to min and max ; ArrowUp and ArrowDown change it by step . Text that is not a number is rejected and the previous value comes back.
Between 1 and 50.
Arrow keys step by 5.
Seats: 12 · Discount: empty
Formatting
Intl.NumberFormat in the active locale. Turn on useGrouping , bound the decimals with minFractionDigits and maxFractionDigits , add literal prefix or suffix text, or pass an ISO currency code. While focused the field shows the plain number for editing.
Label on top, hint and error
labelPosition="top" puts the label above the field. hint adds help text; errors show once the field is touched and invalid , and errorMessages replaces the built-in text for each error kind.
Whole units only.
Disabled, read-only and sizes
disabled blocks all interaction; readonly keeps the formatted value focusable and selectable but ignores typing and arrow keys. size is sm , md (default) or lg .
Reactive Forms
VigValueAccessor next to the component to use formControlName , [formControl] or ngModel . Type the control as number | null ; resetting it empties the field.
Signal Forms
vig-number-input implements FormValueControl<number | null> . Schema min() and max() rules bind to the field's min and max , so typed values are clamped to the allowed range.
18 to 120.
Valid: no · Age: empty
Styling hooks
Internal elements carry a stable data-part and the component's data-scope; both are public API, so removing one is a breaking change. Select a part by both, e.g. [data-scope="number-input"][data-part="field"] { … }: the pair stays within this component when kit components nest, and also reaches parts in overlay panels, which render outside the host. State is exposed through aria-* and, where listed, a data-state; literal values are checked by the API gate, values computed from the component's state follow its documented types. Other data-* attributes listed below (such as data-opening while an overlay animates) are API too. See Customizing.
Scope: [data-scope="number-input"]
| Part | Element | data-state |
|---|---|---|
field | — | |
label | — | |
input | <input> . | — |
hint | vig-hint (a display: contents host; style its text part). | — |
disabled-reason | vig-hint with the disabled reason ( display: contents ). | — |
error | vig-field-error (a display: contents host; style its message part). | — |
Accessibility
- The control is a native
<input type="text" inputmode="decimal">named by a real<label for>, so mobile keyboards show digits and the decimal separator.hideLabelkeeps the label as the accessible name. - ArrowUp and ArrowDown change the value by
step; Enter commits the typed text. It is not aspinbutton, so state the allowed range in the label orhint. - Hint, disabled reason and error are linked through
aria-describedby; a touched, invalid field setsaria-invalid="true". - Currency symbols, prefix and suffix are part of the displayed text, so screen readers announce them with the value.
API
NumberInput
vig-number-inputNumeric field (PrimeNG p-inputnumber territory) with the floating label.
Typing is free-form; the text commits on blur or Enter — parses with the
active locale's group and decimal separators (or a plain ./, decimal),
clamps to min/max, and reverts anything unparseable. The committed value is
shown formatted for the locale (Intl.NumberFormat) with optional grouping,
fraction digits, currency and literal prefix/suffix; while focused the
field shows the plain editable number. Arrow keys step by step. Empty is null.
| Name | Type | Default | Description |
|---|---|---|---|
currency | string | undefined | undefined | ISO 4217 code (e.g. |
dirty | boolean | false | — |
disabled | boolean | false | — |
disabledReasons | readonly WithOptionalFieldTree<DisabledReason>[] | [] | — |
errorMessages | Record<string, string> | — | — |
errors | readonly ValidationError.WithOptionalFieldTree[] | [] | — |
hidden | boolean | false | — |
hideLabel | boolean | false | Visually hides the label — it still names the control for assistive tech — and drops the row reserved for it, giving a shorter control for dense toolbars such as table filters. Pair it with a placeholder. |
hint | string | undefined | undefined | — |
invalid | boolean | false | — |
label | string | — | — |
labelPosition | LabelPosition | 'float' |
|
max | number | undefined | undefined | — |
maxFractionDigits | number | undefined | undefined | Maximum fraction digits shown; typed values are rounded to it on commit. Unset, values keep their full precision (up to 20 digits). |
min | number | undefined | undefined | — |
minFractionDigits | number | undefined | undefined | Minimum fraction digits shown (pads with zeros), e.g. |
name | string | '' | — |
pending | boolean | false | — |
placeholder | string | undefined | undefined | — |
prefix | string | '' | Literal text shown before the formatted value, e.g. |
readonly | boolean | false | — |
required | boolean | false | — |
size | FieldSize | 'md' | — |
step | number | 1 | — |
suffix | string | '' | Literal text shown after the formatted value, e.g. |
touched | boolean | false | — |
useGrouping | boolean | undefined | undefined | Thousands separators in the formatted value; on by default only with |
value | number | null | null | — |
| Name | Payload | Description |
|---|---|---|
touch | void | — |
valueChange | number | null | — |
| Signature | Description |
|---|---|
focus(options?: FocusOptions): void | Moves focus to the control's interactive element (the input, or the
trigger of a popup control). Signal Forms calls it through
|
reset(): void | Drops the text being typed; see |
VigValueAccessor
Bridges the vigdx form fields to Reactive Forms (formControl,
formControlName) and template-driven forms (ngModel). Import it next to
the component; Signal Forms ([formField]) need no accessor.
| Signature | Description |
|---|---|
registerOnChange(fn: (value: unknown) => void): void | — |
registerOnTouched(fn: () => void): void | — |
setDisabledState(disabled: boolean): void | — |
writeValue(value: unknown): void | — |