InputNumber is an input component to provide numerical input.
import { InputNumberModule } from 'primeng/inputnumber';InputNumber is used as a controlled input with ngModel property.
Localization information such as grouping and decimal symbols are defined with the locale property which defaults to the user locale.
Currency formatting is specified by setting the mode option to currency and currency property. In addition currencyDisplay option allows how the currency is displayed, valid values are "symbol" (default) or "code".
Custom texts e.g. units can be placed before or after the input section with the prefix and suffix properties.
Spinner buttons are enabled using the showButtons options and layout is defined with the buttonLayout. Default value is "stacked" whereas "horizontal" and "stacked" are alternatives. Note that even there are no buttons, up and down arrow keys can be used to spin the values with keyboard.
Buttons can also placed vertically by setting buttonLayout as vertical.
A floating label appears on top of the input field when focused. Visit FloatLabel documentation for more information.
IftaLabel is used to create infield top aligned labels. Visit IftaLabel documentation for more information.
When showClear is enabled, a clear icon is displayed to clear the value.
InputNumber provides small and large sizes as alternatives to the base.
The fluid prop makes the component take up the full width of its container when set to true.
Specify the variant property as filled to display the component with a higher visual emphasis than the default outlined style.
When disabled is present, the element cannot be edited and focused.
The invalid state is applied using the invalid property to indicate failed validation, which can be integrated with Angular Forms.
InputNumber can also be used with reactive forms. In this case, the formControlName property is used to bind the component to a form control.
Value to describe the component can either be provided via label tag combined with inputId prop or using ariaLabelledBy, ariaLabel, ariaDescribedBy props. The input element uses spinbutton role in addition to the aria-valuemin, aria-valuemax and aria-valuenow attributes.
<label for="price">Price</label>
<p-inputnumber inputId="price" />
<span id="label_number">Number</span>
<p-inputnumber ariaLabelledBy="label_number" />
<p-inputnumber ariaLabel="Number" />
<p-inputnumber ariaDescribedBy="describe" />
<small id="describe">Information</small>| Key | Function |
|---|---|
| tab | Moves focus to the input. |
| up arrow | Increments the value. |
| down arrow | Decrements the value. |
| home | Set the minimum value if provided. |
| end | Set the maximum value if provided. |