Masked Input
Introduction
Section titled “Introduction”A text field that formats what the user types against a pattern mask: phone numbers, IBANs, postal codes, and other fixed-shape codes. Tokens are 9 (digit), a (letter), and * (letter or digit), plus custom tokens; \ escapes a literal; every other character is a literal inserted automatically. Typed and pasted characters fill the next free slots (characters that fit no slot are dropped), Backspace and Delete skip literals, a selection is replaced, and the caret keeps its logical position across reformatting. value is the raw text (slot characters only); formattedValue adds the literals; placeholder characters are never part of the value. MaskedInput is a Form control with a hidden input that submits the raw or the formatted value. Text Input has no masking (see its section 30), which is why this is a separate component.
- 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.
Use it for
- Values with one fixed shape: national phone numbers, IBANs, postal codes, account or reference numbers.
- Codes where showing the separators while typing prevents errors.
Use something else for
- Dates and times: use Date Input or Date Picker, which validate real dates and respect the business calendar.
- Formats that vary a lot (UK postcodes, international addresses, names): use Text Input with pattern or validate.
- Numbers with locale grouping and decimals: use Number Input.
- One-time codes: use OTP Input.
Anatomy
<div class="aui-field aui-masked-input"> <label class="aui-field__label">Mobile phone</label> <input class="aui-masked-input__input" type="text" dir="ltr" inputmode="tel" value="(555) 010-____" aria-describedby="hint desc error"> <span id="hint" class="aui-visually-hidden">Format: (999) 999-9999, for example (555) 010-0199. 9 is a digit.</span> <div class="aui-field__description">help</div> <div class="aui-field__error">Enter the value in the format (999) 999-9999.</div> <input type="hidden" name="phone" value="555010"></div>Live example
Section titled “Live example”Use the bar above each frame to switch theme, density, direction, and locale.
Masked Input in the Personal preferences showcase
Section titled “Masked Input in the Personal preferences showcase”The part of the Personal preferences showcase that uses Masked Input. Change its options, use it with the keyboard, and watch the event log; the link in the frame opens the full showcase. The bar above the frame switches theme, density, direction, and locale.
Showcase source
// Preferences showcase: a personal settings page with the new form controls. An accent// color with swatches, a contrast hint, and the eyedropper where supported; a satisfaction rating// with half steps; team assignment between two searchable lists (with drag); a work location// cascader whose cities load from a simulated server; a mention comment box with @people and// #tags from a simulated directory; a masked phone number; and an acknowledgement signature.import { Cascader, type CascaderOption, type CascaderValue } from '@absoluteui/components/cascader';import { ColorPicker } from '@absoluteui/components/color-picker';import { MaskedInput, MASK_PRESETS } from '@absoluteui/components/masked-input';import { MentionInput, type MentionSuggestion } from '@absoluteui/components/mention-input';import { Rating } from '@absoluteui/components/rating';import { SignaturePad } from '@absoluteui/components/signature-pad';import { TransferList, type TransferListItem } from '@absoluteui/components/transfer-list';import { action, choice, createShowcase, hostIn, section, status, toggle, wait } from './kit.js';
const sc = createShowcase({ title: 'Personal preferences', description: 'Pick an accent color, rate onboarding, choose your team and location, leave a comment with mentions, and sign.', simulated: true,});
// Appearance: color.const appearance = section(sc, 'Appearance', ['color-picker']);const color = ColorPicker.create(hostIn(appearance), { label: 'Accent color', description: 'Used for your calendar entries and highlights.', value: '#2563eb', presets: [ { value: '#2563eb', label: 'Blue' }, { value: '#15803d', label: 'Green' }, { value: '#b45309', label: 'Amber' }, { value: '#b91c1c', label: 'Red' }, { value: '#7c3aed', label: 'Violet' }, ], recent: ['#0f766e', '#be185d'], contrastWith: '#ffffff', name: 'accent',});sc.listen(color.host, ['aui-change'], 'color');
// Feedback: rating.const feedback = section(sc, 'Feedback', ['rating']);const rating = Rating.create(hostIn(feedback), { label: 'How was your onboarding?', allowHalf: true, value: 4, labels: ['Poor', 'Fair', 'Good', 'Very good', 'Excellent'], name: 'onboarding',});sc.listen(rating.host, ['aui-change'], 'rating');Rating.create(hostIn(feedback), { label: 'Team average', value: 4.5, allowHalf: true, display: true, size: 'sm' });
// Team: transfer list over a realistic directory size.const team = section(sc, 'Team', ['transfer-list']);const FIRST = ['Ana', 'Ben', 'Chen', 'Divya', 'Elif', 'Farah', 'Goran', 'Hana', 'Ivan', 'Jun', 'Kofi', 'Lena', 'Mateo', 'Nora', 'Omar', 'Priya'];const LAST = ['Ruiz', 'Okafor', 'Wang', 'Iyer', 'Kaya', 'Haddad', 'Petrov', 'Sato', 'Novak', 'Kim', 'Mensah', 'Fischer', 'Silva', 'Berg', 'Aziz', 'Rao'];const people: TransferListItem[] = [];for (let i = 0; i < 240; i++) { const name = `${FIRST[i % FIRST.length] ?? ''} ${LAST[Math.floor(i / FIRST.length) % LAST.length] ?? ''}`; people.push({ value: `p${String(i)}`, label: name, description: ['Engineering', 'Finance', 'People', 'Sales'][i % 4] ?? '', ...(i % 37 === 5 ? { disabled: true } : {}) });}const transfer = TransferList.create(hostIn(team), { label: 'Project team', items: people, value: ['p1', 'p2'], draggable: true, maxSelected: 12, name: 'team' });sc.listen(transfer.host, ['aui-change'], 'team');
// Location: lazy cascader.const location = section(sc, 'Work location', ['cascader']);const CITIES: Record<string, string[]> = { 'de/by': ['Munich', 'Nuremberg', 'Augsburg'], 'de/be': ['Berlin'], 'in/ka': ['Bengaluru', 'Mysuru'], 'in/mh': ['Mumbai', 'Pune'], 'us/ca': ['San Francisco', 'Los Angeles', 'San Diego'], 'us/ny': ['New York', 'Buffalo'],};const places: CascaderOption[] = [ { value: 'de', label: 'Germany', children: [{ value: 'by', label: 'Bavaria' }, { value: 'be', label: 'Berlin' }] }, { value: 'in', label: 'India', children: [{ value: 'ka', label: 'Karnataka' }, { value: 'mh', label: 'Maharashtra' }] }, { value: 'us', label: 'United States', children: [{ value: 'ca', label: 'California' }, { value: 'ny', label: 'New York' }] },];const cascader = Cascader.create(hostIn(location), { label: 'Office', options: places, value: ['de', 'by', 'munich'], levelLabels: ['Country', 'State', 'City'], name: 'office', loadChildren: async (_option, { signal, path }) => { await wait(500, signal); sc.log('server answered', { path }); return (CITIES[path.join('/')] ?? []).map((city) => ({ value: city.toLowerCase().replace(/\s+/g, '-'), label: city, isLeaf: true })); },});sc.listen(cascader.host, ['aui-change'], 'cascader');
// Comment: mentions from a simulated directory.const comment = section(sc, 'Comment', ['mention-input']);const TAGS = ['onboarding', 'payroll', 'benefits', 'equipment', 'training'];const findPeople = async (query: string, signal: AbortSignal): Promise<MentionSuggestion[]> => { await wait(250, signal); const q = query.toLowerCase(); return people.filter((p) => p.label.toLowerCase().includes(q)).slice(0, 8).map((p) => ({ id: p.value, label: p.label, description: p.description ?? '' }));};const mention = MentionInput.create(hostIn(comment), { label: 'Note for your manager', description: 'Type @ to mention a colleague or # to add a topic.', maxLength: 500, showCounter: true, name: 'note', triggers: [ { char: '@', label: '@ for people', provider: (query, { signal }) => findPeople(query, signal) }, { char: '#', label: '# for topics', provider: async (query, { signal }) => { await wait(150, signal); return TAGS.filter((t) => t.startsWith(query.toLowerCase())).map((t) => ({ id: t, label: t })); } }, ],});sc.listen(mention.host, ['aui-change', 'aui-mention'], 'mention');
// Contact: masked phone number.const contact = section(sc, 'Contact', ['masked-input']);const phone = MaskedInput.create(hostIn(contact), { label: 'Mobile phone', name: 'phone', ...MASK_PRESETS.phoneUs });sc.listen(phone.host, ['aui-change'], 'phone');
// Acknowledgement: signature.const sign = section(sc, 'Acknowledgement', ['signature-pad']);const signature = SignaturePad.create(hostIn(sign), { label: 'Signature', description: 'Draw your signature, or choose Type to enter your full name.', required: true, name: 'signature' });sc.listen(signature.host, ['aui-change'], 'signature');const summary = status(sign);const summarize = (): void => { const v = signature.value; summary.textContent = v === null ? 'Not signed yet.' : v.mode === 'type' ? `Signed as ${v.text}.` : `Signed with ${String(v.strokes.length)} strokes.`;};signature.host.addEventListener('aui-change', summarize);summarize();
// Options.const controls = [color, rating, transfer, cascader, mention, phone, signature];toggle(sc, 'Disabled', false, (disabled) => { for (const c of controls) c.update({ disabled });});toggle(sc, 'Read-only', false, (readOnly) => { for (const c of controls) c.update({ readOnly });});choice( sc, 'Color picker', [ { value: 'popup', label: 'Popup' }, { value: 'inline', label: 'Inline' }, ], 'popup', (mode) => { color.update({ mode }); }, ['color-picker'],);toggle(sc, 'Half stars', true, (allowHalf) => { rating.update({ allowHalf });}, ['rating']);/** A single path (strings), as opposed to a list of paths. */const isPath = (v: CascaderValue): v is readonly string[] => v?.every((part) => typeof part === 'string') === true;toggle(sc, 'Several offices', false, (multiple) => { const current = cascader.value; cascader.update({ multiple, value: multiple ? (isPath(current) ? [current] : []) : null });}, ['cascader']);action(sc, 'Validate', () => { const invalid = controls.filter((c) => !c.reportValidity()); sc.log('validate', { invalid: invalid.map((c) => c.label) });});action(sc, 'Reset', () => { for (const c of controls) c.reset(); summarize(); sc.log('reset');});Phone number from a preset
Section titled “Phone number from a preset”import { MaskedInput, MASK_PRESETS, type MaskedInputValueDetail } from '@absoluteui/components/masked-input';
const host = document.createElement('div');document.body.append(host);MaskedInput.create(host, { label: 'Mobile phone', name: 'phone', required: true, ...MASK_PRESETS.phoneUs });host.addEventListener('aui-change', (event) => { const { value, formattedValue, complete } = (event as CustomEvent<MaskedInputValueDetail>).detail; console.log(value, formattedValue, complete);});IBAN with a checksum rule
Section titled “IBAN with a checksum rule”import { MaskedInput, MASK_PRESETS } from '@absoluteui/components/masked-input';
/** ISO 13616 mod-97 check. */function ibanValid(raw: string): boolean { const moved = raw.slice(4) + raw.slice(0, 4); let rest = 0; for (const c of moved) { const n = /\d/.test(c) ? c : String(c.charCodeAt(0) - 55); for (const d of n) rest = (rest * 10 + Number(d)) % 97; } return rest === 1;}
const host = document.createElement('div');document.body.append(host);MaskedInput.create(host, { label: 'IBAN', submit: 'raw', ...MASK_PRESETS.iban, validate: (value, { complete }) => (complete && !ibanValid(value) ? 'This IBAN is not valid. Check the digits.' : null),});Custom token: upper-case product code
Section titled “Custom token: upper-case product code”import { MaskedInput } from '@absoluteui/components/masked-input';
const host = document.createElement('div');document.body.append(host);MaskedInput.create(host, { label: 'Product code', mask: 'LLL-9999', tokens: { L: { pattern: /[a-z]/i, transform: (c) => c.toUpperCase(), description: 'L is a letter' } }, example: 'ABC-1234', submit: 'formatted',});Install and start
Section titled “Install and start”npm install @absoluteui/components @absoluteui/core @absoluteui/themeRegistry setup, the theme stylesheet, and the Content Security Policy are covered in Installation.
import { MaskedInput } from '@absoluteui/components/masked-input';import '@absoluteui/components/masked-input/style.css';First use
Section titled “First use”import { MaskedInput, MASK_PRESETS } from '@absoluteui/components/masked-input';import '@absoluteui/components/masked-input/style.css';
const host = document.querySelector<HTMLElement>('#phone');if (host) MaskedInput.create(host, { label: 'Phone', name: 'phone', submit: 'formatted', ...MASK_PRESETS.phoneUs });More usage
import { MaskedInput, MASK_PRESETS } from '@absoluteui/components/masked-input';
const host = document.querySelector<HTMLElement>('#zip');if (host) MaskedInput.create(host, { label: 'ZIP code', name: 'zip', ...MASK_PRESETS.zipUs4 });Using Angular? See Masked Input for Angular.
API reference
Section titled “API reference”Factory
Section titled “Factory”MaskedInput.create(host: HTMLElement, options: MaskedInputOptions): MaskedInputGlobal configuration key: maskedInput (see Configuration).
Options
Section titled “Options”| Option | Type | Default | Description |
|---|---|---|---|
label |
string |
Visible label and accessible name. Required. | |
hideLabel |
boolean |
false |
Visually hide the label; it remains the accessible name. |
description |
string |
Help text referenced by aria-describedby. | |
mask |
string |
Pattern: 9 digit, a letter, * letter or digit, custom token characters, \ escapes; anything else is a literal. Required. | |
tokens |
Readonly<Record<string, MaskToken>> |
Custom tokens { pattern, transform?, description? }; override built-ins with the same character. | |
value |
string |
"''" |
Initial raw value (formatted text is accepted and parsed); also restored by reset(). |
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 |
'numeric' | 'text' | '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: { formattedValue: string; complete: boolean }) => string | null |
Consumer validation (for example a checksum); return a message to mark the value invalid. | |
icons |
Partial<{ error: IconRef }> |
Icon slot overrides. | |
validationTiming |
'blur' | 'input' | 'submit' |
"blur" |
When validation messages first appear; afterwards they update live. Globally configurable. |
placeholderChar |
string |
"_" |
Character shown in empty slots while the template is visible. Globally configurable. |
showMaskOnFocus |
boolean |
true |
Show the whole template while focused. Globally configurable. |
locale |
string |
"en-US" |
Message locale. Globally configurable. Inherited from common configuration. |
Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
host |
HTMLElement |
Consumer host; its children are owned by the component. |
input |
HTMLInputElement |
The native input. |
value |
string |
Raw value: slot characters only. |
formattedValue |
string |
The value with literals, up to the last filled slot. |
complete |
boolean |
At least minLength (default every) slot is filled. |
name |
string | null |
Form field name. |
label |
string |
Label text. |
disabled |
boolean |
Disabled state. |
validity |
FieldValidity |
{ valid, error, message }; computed on every change. |
dirty |
boolean |
Value differs from the initial value. |
touched |
boolean |
Focus has left the control at least once. |
options |
Readonly<MaskedInputOptions> |
Current instance options. |
Methods
Section titled “Methods”| Method | Description |
|---|---|
setValue(value: string): void |
Set from raw or formatted text; characters that fit no slot are dropped (no event). |
update(options: Partial<MaskedInputOptions>): void |
Merge and apply options; a new mask re-fits the value. |
reportValidity(): boolean |
Show messages now and return validity. |
setCustomError(message: string | null): void |
External error; cleared when the user edits. |
getFormValue(): string |
Raw or formatted value, per submit. |
focus(): void |
Focus the input. |
reset(): void |
Restore the initial value and clear dirty/touched/submitted state. |
destroy(): void |
Remove rendering, listeners, registration, and subscriptions. |
Events
Section titled “Events”| Event | Detail | Bubbles | Cancelable | Description |
|---|---|---|---|---|
aui-input |
MaskedInputValueDetail |
Yes | No | The raw value changed: { value, formattedValue, complete, validity }. |
aui-change |
MaskedInputValueDetail |
Yes | No | Focus left with a changed value. |
CSS classes
Section titled “CSS classes”All rules live in the aui.components cascade layer, so application styles override them without specificity battles.
| Class | Purpose |
|---|---|
aui-field aui-masked-input |
Host. |
aui-masked-input--invalid | --disabled |
State modifiers on the host. |
aui-field__label | __required | __description | __error |
Shared field chrome. |
aui-masked-input__input |
Native input showing the formatted value. |
Icon slots
Section titled “Icon slots”| Slot | Default icon |
|---|---|
error |
alert-circle |
Design tokens
Section titled “Design tokens”Tokens this stylesheet reads (verified in CI). Override them in a theme or with the Theme Designer.
--aui-border-width | --aui-color-border | --aui-color-border-strong | --aui-color-disabled-bg | --aui-color-error-fg | --aui-color-focus-ring | --aui-color-surface | --aui-color-surface-sunken | --aui-color-text | --aui-color-text-disabled | --aui-color-text-muted | --aui-control-height-md | --aui-control-padding-x | --aui-duration-fast | --aui-easing-standard | --aui-focus-ring-width | --aui-font-family-sans | --aui-font-size-md | --aui-font-size-sm | --aui-font-weight-medium | --aui-icon-size-sm | --aui-line-height-normal | --aui-line-height-tight | --aui-radius-md | --aui-space-1
TypeScript definitions
interface MaskToken { readonly pattern: RegExp; readonly transform?: (char: string) => string; readonly description?: string }interface MaskPreset { readonly mask: string; readonly tokens?: Readonly<Record<string, MaskToken>>; readonly minLength?: number; readonly inputMode?: 'numeric' | 'text' | 'tel'; readonly autocomplete?: string; readonly example?: string }interface MaskedInputConfig { validationTiming: 'blur' | 'input' | 'submit'; placeholderChar: string; showMaskOnFocus: boolean }interface MaskedInputOptions extends Partial<MaskedInputConfig> { label: string; hideLabel?: boolean; description?: string; mask: string; tokens?: Readonly<Record<string, MaskToken>>; value?: string; minLength?: number; name?: string; submit?: 'raw' | 'formatted'; placeholder?: string; example?: string; formatHint?: string; required?: boolean; disabled?: boolean; readOnly?: boolean; inputMode?: 'numeric' | 'text' | 'tel' | 'decimal'; autocomplete?: string; direction?: 'ltr' | 'rtl' | 'auto'; validate?: (value: string, context: { readonly formattedValue: string; readonly complete: boolean }) => string | null; locale?: string; icons?: Partial<{ error: IconRef }>;}interface MaskedInputValueDetail { value: string; formattedValue: string; complete: boolean; validity: FieldValidity }Accessibility and performance
Section titled “Accessibility and performance”Accessibility
Section titled “Accessibility”Pattern: Native text input (textbox) with a programmatically associated format hint; no custom widget role.
Checked on every docs build: the showcase passes axe (WCAG 2.2 A and AA rules) in the default, dark, and high-contrast themes and right to left; the playground loads without errors and passes axe before and after every on/off option is switched, with no Content Security Policy violations.
Keyboard
Section titled “Keyboard”| Key | Context | Action |
|---|---|---|
| Printable characters | Field | Fill the next free slot; characters that fit no slot are ignored and literals are inserted automatically. |
| Backspace | Field | Delete the slot character before the caret, skipping literals. |
| Delete | Field | Delete the slot character after the caret, skipping literals. |
| Ctrl+V / Cmd+V | Field | Paste: matching characters fill the slots from the caret; separators and other characters are dropped. |
| Arrow keys, Home, End | Field | Native caret movement. |
| Element | Role |
|---|---|
| field | textbox (native input) |
| format hint | none (visually hidden text referenced by aria-describedby) |
ARIA attributes
Section titled “ARIA attributes”| Attribute | Element | Value |
|---|---|---|
aria-describedby |
field | the format hint (‘Format: (999) 999-9999. 9 is a digit.’), help text, and error |
aria-invalid |
field | true while an error is shown |
required |
field | native required when required |
Native input focus; on focus the caret moves to the first empty slot.
WCAG 2.2 success criteria addressed
Section titled “WCAG 2.2 success criteria addressed”| Criterion | Level | Note |
|---|---|---|
| 1.3.1 Info and Relationships | A | |
| 1.3.5 Identify Input Purpose | AA | |
| 2.1.1 Keyboard | A | |
| 3.3.1 Error Identification | A | |
| 3.3.2 Labels or Instructions | A | |
| 3.3.3 Error Suggestion | AA | |
| 4.1.2 Name, Role, Value | A |
Automated test results: Accessibility and compliance.
Notes and known caveats
Section titled “Notes and known caveats”- The input’s value is the formatted text, so screen readers read what is shown; placeholder characters are only part of the template, never of the value.
- The format hint is generated from the mask (or set with formatHint or example) and announced with the field (3.3.2).
- Incomplete values get a message that repeats the format (3.3.3).
- While focused with showMaskOnFocus, some screen readers read the placeholder characters of empty slots; set showMaskOnFocus: false where that is a concern.
- Manual screen-reader verification (NVDA, JAWS, VoiceOver) is pending.
Performance
Section titled “Performance”| Import cost | Minified | gzip | brotli | CSS brotli |
|---|---|---|---|---|
@absoluteui/components/masked-input |
47.5 kB | 16.2 kB | 14.5 kB | 0.8 kB |
Measured at build time, including every AbsoluteUI module the component pulls in. No third-party runtime dependencies.
| Budget (enforced in CI) | Limit |
|---|---|
| MaskedInput.create, per instance | < 2 ms average in headless Chromium |
| Reformat per keystroke | O(mask length) |
Tested scale: Masks up to 64 slots; paste of 1,000 characters.
Each edit re-fits the raw value and reformats it in one pass over the mask.
Measured run times: Performance.
Details
Section titled “Details”States
Empty; partially filled; complete; template shown (focused); required; disabled; read-only; invalid (incomplete or custom).
State transitions
| From | Trigger | To |
|---|---|---|
| unfocused | focus | template shown (showMaskOnFocus), caret at the first empty slot |
| any | a fitting character typed or pasted | slot filled, literals added; aui-input |
| any | a character that fits no slot | unchanged |
| any | Backspace / Delete | the slot character before / after the caret removed; following characters move up |
| focused | blur | formatted value without the template; aui-change when the value changed |
| partially filled | validation shown | “Enter the value in the format …” |
Accessibility notes
- The input’s value is the formatted text, so screen readers read what sighted users see.
- The format hint is generated from the mask (“Format: (999) 999-9999. 9 is a digit.”) or from
exampleorformatHint(WCAG 3.3.2). Give custom tokens adescription. - Incomplete values get a message that repeats the format (3.3.3). Set
autocomplete(presets do) for 1.3.5. - Set
showMaskOnFocus: falsewhere screen readers reading the placeholder characters is a concern.
Responsive behavior
The field fills its container.
Right-to-left
The label and chrome follow the document direction. The value is left to right by default, because phone numbers, IBANs, and codes are read left to right in every locale; use direction for letter masks in right-to-left scripts.
Theming
Colors come from global tokens in all three themes; numerals are tabular so slots line up. Forced colors keep the native input colors with a Highlight focus outline.
Global configuration
configureAbsoluteUI({ components: { maskedInput: { placeholderChar: '·', showMaskOnFocus: false } } });Component configuration
Instance validationTiming, placeholderChar, showMaskOnFocus, and locale override configuration; configuration changes re-render existing fields.
Timezones
Not applicable. The date presets shape digits only and do not know about time zones or the business calendar; use Date Input for dates.
Icons
icons.error (default alert-circle) for the validation message.
Security
The value is written to a native input as text; no HTML is rendered. Custom token patterns are tested against single characters (global and sticky flags are removed).
Data handling
No persistence, network access, or telemetry. autocomplete is off unless set.
Supported data scale
Masks up to 64 slots; pastes of 1,000 characters are reduced to the slots in one pass.
Edge cases
- Pasting
+1 (555) 010-0199into+1 (999) 999-9999skips the literal prefix, so the1is not taken as a digit. - Typing a literal character (for example
() is ignored; the mask adds literals itself. - Deleting in the middle moves the following characters up; a character that no longer fits its new slot is dropped.
update({ mask })re-fits the current raw value to the new mask.- Values for
submit: 'formatted'stop at the last filled slot, without trailing literals or placeholders.
Errors
| Code | Category | Cause |
|---|---|---|
MASKED_INPUT_OPTIONS |
configuration | Blank label, empty mask or a mask without tokens, invalid custom tokens, minLength outside 1..slots, a non-string value, unknown submit or direction, a non-function validate. |
CFG_INVALID_VALUE / CFG_UNKNOWN_OPTION |
configuration | Invalid configuration (for example a placeholderChar longer than one character). |
Invalid options throw before the host is modified; an invalid update() leaves the previous state intact.
Known limitations
- Edits go through
beforeinput, so the browser’s undo and redo do not apply. - One shape per mask; optional trailing slots are expressed with
minLength. - IME composition is re-parsed after it commits.
- Manual screen-reader verification is pending.
Unsupported scenarios
- Masks that change with the typed value (for example per-country phone formats).
- Locale-aware numbers, currency, or decimals.
(c) 2026 Kasadara Technology Solutions Pvt Ltd. AbsoluteUI is free to use under the AbsoluteUI Free Use License; it is not open source.