Number input

A text field for numbers that parses and formats with the active locale. Use it for quantities, amounts and prices; the value is a number , or null when empty.

  • vig-number-input
Import
import { NumberInput } from '@vigdx/ui/number-input';

Basic

Bind [(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

Once the field loses focus the value is shown with 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.

The minimum budget is $500.

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

Import VigValueAccessor next to the component to use formControlName , [formControl] or ngModel . Type the control as number | null ; resetting it empties the field.

{
  "guests": null,
  "deposit": null
}

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"]

NumberInput styling hooks
Part Element data-state
field Positioned wrapper of the label and the control. —
label The visible (or floating) label. —
input The native <input> . —
hint The vig-hint (a display: contents host; style its text part). —
disabled-reason The vig-hint with the disabled reason ( display: contents ). —
error The 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. hideLabel keeps the label as the accessible name.
  • ArrowUp and ArrowDown change the value by step; Enter commits the typed text. It is not a spinbutton, so state the allowed range in the label or hint.
  • Hint, disabled reason and error are linked through aria-describedby; a touched, invalid field sets aria-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-input component

Numeric 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.

NumberInput props
Name Type Default Description
currencystring | undefinedundefined

ISO 4217 code (e.g. 'EUR') formatting the value as currency in the active locale; implies grouping and the currency's fraction digits.

dirtybooleanfalse
—
disabledbooleanfalse
—
disabledReasonsreadonly WithOptionalFieldTree<DisabledReason>[][]
—
errorMessagesRecord<string, string>—
—
errorsreadonly ValidationError.WithOptionalFieldTree[][]
—
hiddenbooleanfalse
—
hideLabelbooleanfalse

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.

hintstring | undefinedundefined
—
invalidbooleanfalse
—
label required string—
—
labelPositionLabelPosition'float'

float (default) rests the label inside the field; top sets it above a shorter field, for forms laid out with labels over their controls.

maxnumber | undefinedundefined
—
maxFractionDigitsnumber | undefinedundefined

Maximum fraction digits shown; typed values are rounded to it on commit. Unset, values keep their full precision (up to 20 digits).

minnumber | undefinedundefined
—
minFractionDigitsnumber | undefinedundefined

Minimum fraction digits shown (pads with zeros), e.g. 2 for 12.50.

namestring''
—
pendingbooleanfalse
—
placeholderstring | undefinedundefined
—
prefixstring''

Literal text shown before the formatted value, e.g. '~ '.

readonlybooleanfalse
—
requiredbooleanfalse
—
sizeFieldSize'md'
—
stepnumber1
—
suffixstring''

Literal text shown after the formatted value, e.g. ' kg'.

touchedbooleanfalse
—
useGroupingboolean | undefinedundefined

Thousands separators in the formatted value; on by default only with currency.

value model number | nullnull
—

VigValueAccessor

directive

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.

VigValueAccessor methods
Signature Description
registerOnChange(fn: (value: unknown) => void): void
—
registerOnTouched(fn: () => void): void
—
setDisabledState(disabled: boolean): void
—
writeValue(value: unknown): void
—

Are you sure?