An input field that restricts user input to a mask pattern and formats the visible value.
- 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 the value does not fill the required positions of the mask. -
custom-error— Renders content when a custom message is set with `setCustomValidity()`. -
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. -
prefixed— Added to the container and the input when an element that is not hidden is in the prefix slot. -
suffixed— Added to the container and the input when an element that is not hidden is in the suffix slot. -
filled— Added to the container and the input when the control has a value. -
labelled— Added to the container in the material theme when the control has a label. -
start— The wrapper of the prefix in the material theme. -
notch— The wrapper of the label in the material theme. -
filler— The outline segment between the notch and the end in the material theme. -
end— The wrapper of the suffix in the material theme.
Properties
Section titled "Properties"outlined
Section titled "outlined"Whether the control has an outlined appearance.
outlined: boolean prompt
Section titled "prompt"The prompt symbol to use for unfilled parts of the mask pattern.
prompt: string value
Section titled "value"The value of the control. Its format depends on valueMode.
An empty value is always an empty string, regardless of the value mode.
value: string valueMode
Section titled "valueMode"The format of the value and of the submitted form value:
raw: The input without the mask literals and prompts (e.g. "5551234567")withFormatting: The input with the mask formatting (e.g. "(555) 123-4567")
An empty value is always an empty string, regardless of the value mode.
valueMode: MaskInputValueMode Methods
Section titled "Methods"Removes focus from the control.
blur(): void Returns void
focus
Section titled "focus"Sets focus on the control.
focus(options: FocusOptions): void Parameters
- options:
FocusOptions
Returns void
isValidMaskPattern
Section titled "isValidMaskPattern"Returns whether the current masked input is valid according to the mask pattern.
An empty control is valid. The required validator checks it.
isValidMaskPattern(): boolean Returns boolean
select
Section titled "select"Selects all the text inside the input.
select(): void Returns void
Events
Section titled "Events"onChange
Section titled "onChange"Emitted when the user commits a change to the value of the control.
onChange(args: CustomEvent<string>): void Parameters
- args:
CustomEvent<string>
Returns void
onInput
Section titled "onInput"Emitted when the control receives user input.
onInput(args: CustomEvent<string>): void Parameters
- args:
CustomEvent<string>