A masked input is an input field where a developer can control user input and format the visible value, based on configurable rules

Slots
prefix — Renders content before the input
suffix — Renders content after the input
helper-text — Renders content below the input
value-missing — Renders content when the required validation fails.
bad-input — Renders content when a required mask pattern validation fails.
custom-error — Renders content when setCustomValidity(message) is set.
invalid — Renders content when the component is in invalid state (validity.valid = false).
CSS Parts
container — The main wrapper that holds all main input elements
input — The native input element
label — The native label element
prefix — The prefix wrapper
suffix — The suffix wrapper
helper-text — The helper text wrapper

The label for the control.

label: string

The masked pattern of the component.

mask: string

The masked pattern of the component.

mask: string

Whether the control will have outlined appearance.

outlined: boolean

The placeholder attribute of the control.

placeholder: string

The prompt symbol to use for unfilled parts of the mask pattern.

prompt: string

The prompt symbol to use for unfilled parts of the mask pattern.

prompt: string

Makes the control a readonly field.

readOnly: boolean

The value of the input.

Regardless of the currently set value-mode, an empty value will return an empty string.

value: string

Dictates the behavior when retrieving the value of the control:

  • raw: Returns clean input (e.g. "5551234567")
  • withFormatting: Returns with mask formatting (e.g. "(555) 123-4567")

Empty values always return an empty string, regardless of the value mode.

valueMode: MaskInputValueMode

Removes focus from the control.

blur(): void

Returns void

Sets focus on the control.

focus(options: FocusOptions): void

Parameters

  • options: FocusOptions

Returns void

Returns whether the current masked input is valid according to the mask pattern.

isValidMaskPattern(): boolean

Returns boolean

Selects all the text inside the input.

select(): void

Returns void

Replaces the selected text in the control and re-applies the mask

setRangeText(replacement: string, start: number, end: number, selectMode: RangeTextSelectMode): void

Parameters

Returns void

Sets the text selection range of the control

setSelectionRange(start: number, end: number, direction: SelectionRangeDirection): void

Parameters

Returns void

Emitted when an alteration of the control's value is committed by the user

onChange(args: CustomEvent<string>): void

Parameters

Returns void

Emitted when the control receives user input

onInput(args: CustomEvent<string>): void

Parameters

Returns void