Masked Input for Angular
Introduction
Section titled “Introduction”A text field that formats input against a pattern mask (phone numbers, IBANs, postal codes, fixed-shape codes). Typed and pasted characters fill the next free slots, Backspace and Delete skip literals, and the caret keeps its logical position. The value is the raw text; formattedValue adds the literals. A Form control with a hidden input submitting the raw or formatted value.
- Pattern masksDigits, letters, alphanumerics, escapes, and custom tokens with transforms such as upper case.
- PresetsPhone, IBAN, ZIP, and ISO date shapes ready to spread into the options.
- Raw or formattedvalue is the raw text, formattedValue adds the literals; submit either one.
- Caret and pastePaste fills the slots, Backspace skips literals, and the caret stays where you expect.
- Screen-reader friendlyA generated format hint is read with the field; placeholders never enter the value.
Behavior, design tokens, and limitations are described on the Masked Input page; this page covers the Angular API.
Live example
Section titled “Live example”import { Component } from '@angular/core';import { AuiMaskedInput } from '@absoluteui/angular/masked-input';
@Component({ selector: 'app-bank-details', imports: [AuiMaskedInput], template: `<aui-masked-input label="Sort code" mask="99-99-99" [(value)]="sortCode"></aui-masked-input>`,})export class BankDetailsComponent { sortCode = '';}Install and start
Section titled “Install and start”npm install @absoluteui/angular @absoluteui/components @absoluteui/core @absoluteui/themeSetup with provideAbsoluteUI() is covered in Getting started. Styles are included with the component.
import { AuiMaskedInput } from '@absoluteui/angular/masked-input';Defaults for every instance: provideAbsoluteUIConfig({ components: { maskedInput: { ... } } }) (see Configuration).
API reference
Section titled “API reference”<aui-masked-input>
Section titled “<aui-masked-input>”Class AuiMaskedInput; template reference #ref="auiMaskedInput".
Server rendering: Renders on the server; the browser re-creates it after hydration.
Angular forms: implements ControlValueAccessor and Validator; the form value is string. Bind [formControl], formControlName, or [(ngModel)]; validation messages of the component report through the aui error key. See Forms.
Inputs
Section titled “Inputs”| Input | Type | Default | Description |
|---|---|---|---|
label |
string |
Required. Visible label and accessible name. | |
hideLabel |
boolean |
false |
Visually hide the label; it remains the accessible name. |
description |
string |
Help text referenced by aria-describedby. | |
mask |
string |
Required. Pattern: 9 digit, a letter, * letter or digit, custom token characters, \ escapes; anything else is a literal. | |
tokens |
Readonly<Record<string, MaskToken>> |
Custom tokens { pattern, transform?, description? }; override built-ins with the same character. | |
minLength |
number |
Raw characters needed for a complete value (default: every slot). | |
name |
string |
Form field name (hidden input). | |
submit |
"raw" | "formatted" |
'raw' |
What the hidden input and getFormValue() carry. |
placeholder |
string |
Shown while empty and unfocused (default: the template with placeholder characters). | |
example |
string |
Example value read in the generated format hint. | |
formatHint |
string |
Replaces the generated format hint. | |
required |
boolean |
false |
Empty value is invalid; shows the required indicator. |
disabled |
boolean |
false |
Disables the field. |
readOnly |
boolean |
false |
Focusable and submitted, not editable. |
inputMode |
"text" | "numeric" | "tel" | "decimal" |
Virtual keyboard hint (default numeric for digit-only masks). | |
autocomplete |
string |
'off' |
Native autocomplete token. |
direction |
"ltr" | "rtl" | "auto" |
'ltr' |
Text direction of the value. |
validate |
(value: string, context: { readonly formattedValue: string; readonly complete: boolean; }) => string | null |
Consumer validation (for example a checksum); return a message to mark the value invalid. | |
icons |
Partial<MaskedInputIcons> |
Icon slot overrides. | |
validationTiming |
ValidationTiming |
'blur' |
When validation messages first appear; afterwards they update live. |
placeholderChar |
string |
'_' |
Character shown in empty slots while the template is visible. |
showMaskOnFocus |
boolean |
true |
Show the whole template while focused. |
locale |
string |
'en-US' |
Message locale. |
Two-way bindings
Section titled “Two-way bindings”| Model | Type | Change output | Description |
|---|---|---|---|
[(value)] |
string |
(valueChange) |
The value: [(value)] without forms; with Angular forms, bind the form control instead. |
Outputs
Section titled “Outputs”| Output | Payload | Description |
|---|---|---|
(valueInput) |
MaskedInputValueDetail |
The raw value changed: { value, formattedValue, complete, validity }. Re-emits aui-input. |
(changed) |
MaskedInputValueDetail |
Focus left with a changed value. Re-emits aui-change. |
Methods
Section titled “Methods”Call them through a viewChild query or a template reference.
| Method | Description |
|---|---|
reportValidity(): boolean | undefined |
Show messages now and return validity. |
setCustomError(message: string | null): void |
External error; cleared when the user edits. |
getFormValue(): string | undefined |
Raw or formatted value, per submit. |
focus(): void |
Focus the input. |
reset(): void |
Restore the initial value and clear dirty/touched/submitted state. |
Accessibility and performance
Section titled “Accessibility and performance”Pattern: Native text input (textbox) with a programmatically associated format hint; no custom widget role.
The Angular component renders the framework-neutral component, so its keyboard support, roles, WCAG 2.2 criteria, budgets, and import cost apply unchanged: see Masked Input: Accessibility and performance.
(c) 2026 Kasadara Technology Solutions Pvt Ltd. AbsoluteUI is free to use under the AbsoluteUI Free Use License; it is not open source.