Skip to main content
Neural UIv2.0.0Documentation
View v1 GitHub

InputMask

Guide text entry with digit, letter and alphanumeric mask positions.

Category
Forms and selection
Import
@neural-ui/core/input-mask
Selector
neu-input-mask
import { NeuInputMaskComponent } from '@neural-ui/core/input-mask';

Usage

9 accepts a digit, A accepts a letter and * accepts a letter or digit. Other characters are literals. The value is the displayed masked string, including inserted literals. A mask guides editing; use form validators for required length or business rules.

Examples

Interact with the example and open Code for its complete implementation.

Examples

A accepts letters, 9 accepts digits and * accepts letters or digits. Other characters are literals.

Try and configure

Change the controls and try the live preview. Expand the application value or event to inspect its real data; the generated template stays with the configurator.

Try and configure

Live preview

Generated template: the options above. The Code tab contains the imports and state.

template.html
<neu-input-mask
  [(value)]="text"
  mask="999 999 999"
  [label]="'Phone'"
/>

Signal Forms

Bind FormField once to the component; the field owns value and validation. The schema requires the full eleven-character phone mask. Leave the control to mark it touched, then reset the field to clear both value and interaction state.

Signal Forms guide

Signal Forms

Valid: false

Value and events

Use [(value)] or [value] with (valueChange), not both. The model synchronizes application state; other Outputs communicate their documented events. touch reports leaving/visiting the control, not a new value.

Accessibility and keyboard

Use a label that describes the value, and a placeholder that shows its expected format. The mask does not replace required or business validation. Keep error text associated through ariaDescribedBy; users can type, paste and correct characters with their normal editing keys.

Key
Action
Tab Enters and leaves the control.
Typing / Paste Fills compatible mask positions.

API

Inputs, models and Outputs come from the pinned Core contract. Click named types to open their definitions. This component has no public template slots.

Inputs

Configure the component with [property]="value". Your application supplies these values; the component does not replace the state you pass in.

Name
Type
Default
Template binding
Description
dirtybooleanfalse[dirty]Form state indicating that the user has changed the value.
disabledbooleanfalse[disabled]Prevents user interaction.
errorMessagestring''[errorMessage]Visible error message associated with the field.
errorsreadonly ValidationError.WithOptionalFieldTree[][][errors]Validation errors supplied by the form or the application.
hiddenbooleanfalse[hidden]Hides the control according to the form state.
hintstring''[hint]Help text associated with the field.
inputIdstringinject(NeuIdGenerator).getId('neu-input-mask-')Derived default[inputId]Stable identifier of the native control; automatically generated when omitted.
invalidbooleanfalse[invalid]Displays the invalid state; it does not add a validation rule.
labelstring''[label]Visible label and accessible name of the control.
maskstring''[mask]Mask grammar: 9 digit, A letter, * alphanumeric; other characters are literal.
maxLengthnumber | undefinedundefined[maxLength]Form-supplied maximum string length. Configure the validator in your form schema.
minLengthnumber | undefinedundefined[minLength]Form-supplied minimum string length. Configure the validator in your form schema.
namestring''[name]Name associated with the native form control.
patternreadonly RegExp[][][pattern]Form-supplied regular-expression validation constraints.
pendingbooleanfalse[pending]Form state indicating that asynchronous validation is pending.
placeholderstring''[placeholder]Text shown when the field has no selected value.
readonlybooleanfalse[readonly]Keeps the control focusable and readable without accepting edits.
requiredbooleanfalse[required]Marks the field as required; use a form validator to enforce it.
touchedbooleanfalse[touched]Form state indicating that the control has been visited.

Models

A model supports [(property)]="signal" or the [property] and (propertyChange) pair. Choose one form, not both.

Name
Type
Default
Template binding
Description
valuestring''[(value)]Single committed string, synchronized through valueChange.

Outputs

Listen to an event with (event)="handler($event)". The table explains the data your handler receives and how to use it.

Name
Payload
Template binding
Description
touchvoid(touch)="onTouch($event)"Notifies the form that the control has been touched; not a value change.

Templates

ng-content projects content into the component. TemplateRef inputs receive a template; ng-template directives identify templates with a typed context. A directive shared by an entrypoint is not necessarily a slot of this component.

This component does not expose content projection or public customization templates.

Styles and tokens

Load Core styles once. Use the public tokens below for local customization or a preset for application-wide changes. Keep labels, focus, selected options and disabled states readable in both light and dark themes.

Specific tokens

This component uses shared theme tokens rather than dedicated component hooks.

Shared tokens used

Override these on a local wrapper to affect this example. An override on :root affects other components that use the same token.

Token
Purpose here
Other impact
Default / fallback
--neu-border Normal control and cell borders Shared by other Core consumers; scope the override. rgba(15, 23, 42, 0.08)
--neu-focus-ring Normal keyboard-focus ring Shared by other Core consumers; scope the override. 0 0 0 var(--neu-focus-ring-width) rgba(0, 122, 255, 0.15)
--neu-primary Brand color for active controls and emphasis Shared by other Core consumers; scope the override. #007aff
--neu-radius Control corner radius Shared by other Core consumers; scope the override. 8px
--neu-surface Main field, header or control surface Shared by other Core consumers; scope the override. #ffffff
--neu-text Main text and inherited icon color Shared by other Core consumers; scope the override. #0f172a
--neu-text-muted Secondary labels and supporting content Shared by other Core consumers; scope the override. #475569
--neu-transition Timing of state changes Shared by other Core consumers; scope the override. 200ms ease