InputMask

InputMask component is used to enter input in a certain format such as numeric, date, currency and phone.

import { InputMaskModule } from 'primeng/inputmask';

InputMask is used as a controlled input with ngModel properties.

Mask format can be a combination of the following definitions; a for alphabetic characters, 9 for numeric characters and * for alphanumberic characters. In addition, formatting characters like ( , ) , - are also accepted.

SSN
Phone
Serial Number

When the input does not complete the mask definition, it is cleared by default. Use autoClear property to control this behavior. In addition, ? is used to mark anything after the question mark optional.

Default placeholder for a mask is underscore that can be customized using slotChar property.

Specify the variant property as filled to display the component with a higher visual emphasis than the default outlined style.

FloatLabel visually integrates a label with its form element. Visit FloatLabel documentation for more information.

IftaLabel is used to create infield top aligned labels. Visit IftaLabel documentation for more information.

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

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.

InputMask can also be used with reactive forms. In this case, the formControlName property is used to bind the component to a form control.

Screen Reader

InputMask directive is used with a native input element that implicitly includes any passed attribute. Value to describe the component can either be provided via label tag combined with id attribute or using aria-labelledby, aria-label attributes.

<label for="date">Date</label>
<input pInputText id="date" pInputMask="99/99/9999" />

<span id="phone">Phone</span>
<input pInputText pInputMask="(999) 999-9999" aria-labelledby="phone" />

<input pInputText pInputMask="99" aria-label="Age" />

Keyboard Support

KeyFunction
tabMoves focus to the input.
Figma UI Kit
The official Figma UI Kit for Prime UI libraries, the essential resource for designing with PrimeOne components.