A masked input is an input field where a developer can control user input and format the visible value, based on configurable rules
- Element
-
igc-mask-input
- 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
Properties
Section titled "Properties"disabled
Section titled "disabled"Inherited from: MaskBehaviorMixin( IgcInputBaseComponent )
The disabled state of the component.
disabled: boolean Defined in src/internals/mixins/forms/types.ts:30
invalid
Section titled "invalid"Inherited from: MaskBehaviorMixin( IgcInputBaseComponent )
Sets the control into invalid state (visual state only).
invalid: boolean Defined in src/internals/mixins/forms/types.ts:37
label
Section titled "label"Inherited from: MaskBehaviorMixin( IgcInputBaseComponent )
The label for the control.
label: string Defined in src/components/input/input-base.ts:85
Inherited from: MaskBehaviorMixin( IgcInputBaseComponent )
The name of the control, submitted with the form data.
name: string Defined in src/internals/mixins/forms/types.ts:43
outlined
Section titled "outlined"Inherited from: MaskBehaviorMixin( IgcInputBaseComponent )
Whether the control will have outlined appearance.
outlined: boolean = false Defined in src/components/input/input-base.ts:71
placeholder
Section titled "placeholder"Inherited from: MaskBehaviorMixin( IgcInputBaseComponent )
The placeholder text of the control.
placeholder: string Defined in src/components/input/input-base.ts:78
readOnly
Section titled "readOnly"Inherited from: MaskBehaviorMixin( IgcInputBaseComponent )
Makes the control a readonly field.
readOnly: boolean Defined in src/internals/mixins/mask-behavior.ts:83
valueMode
Section titled "valueMode"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 = 'raw' Defined in src/components/mask-input/mask-input.ts:111
tagName
Section titled "tagName"The tagName read-only property of the Element interface returns the tag name of the element on which it's called.
tagName: "igc-mask-input" = 'igc-mask-input' Defined in src/components/mask-input/mask-input.ts:62
Accessors
Section titled "Accessors"defaultValue
Section titled "defaultValue"Inherited from: MaskBehaviorMixin( IgcInputBaseComponent )
get defaultValue(): any Defined in src/internals/mixins/forms/types.ts:182
The initial value of the component.
set defaultValue(value: unknown): void Defined in src/internals/mixins/forms/types.ts:182
Parameters
- value:
unknown
Returns void
Inherited from: MaskBehaviorMixin( IgcInputBaseComponent )
Returns the HTMLFormElement associated with this element.
get form(): HTMLFormElement | null Defined in src/internals/mixins/forms/types.ts:46
Returns HTMLFormElement | null
The mask pattern of the component.
get mask(): string Defined in src/components/mask-input/mask-input.ts:152
Returns string
The masked pattern of the component.
set mask(value: string): void Defined in src/components/mask-input/mask-input.ts:145
Parameters
- value:
string
Returns void
prompt
Section titled "prompt"The prompt symbol to use for unfilled parts of the mask pattern.
get prompt(): string Defined in src/components/mask-input/mask-input.ts:170
Returns string
The prompt symbol to use for unfilled parts of the mask pattern.
set prompt(value: string): void Defined in src/components/mask-input/mask-input.ts:163
Parameters
- value:
string
Returns void
required
Section titled "required"Inherited from: MaskBehaviorMixin( IgcInputBaseComponent )
get required(): any Defined in src/internals/mixins/forms/types.ts:207
When set, makes the component a required field for validation.
set required(value: boolean): void Defined in src/internals/mixins/forms/types.ts:207
Parameters
- value:
boolean
Returns void
validationMessage
Section titled "validationMessage"Inherited from: MaskBehaviorMixin( IgcInputBaseComponent )
A string containing the validation message of this element.
get validationMessage(): string Defined in src/internals/mixins/forms/types.ts:55
Returns string
validity
Section titled "validity"Inherited from: MaskBehaviorMixin( IgcInputBaseComponent )
Returns a ValidityState object which represents the different validity states the element can be in, with respect to constraint validation.
get validity(): ValidityState Defined in src/internals/mixins/forms/types.ts:52
Returns ValidityState
value
Section titled "value"The value of the control.
get value(): string Defined in src/components/mask-input/mask-input.ts:129
Returns string
The value of the input.
Regardless of the currently set value-mode, an empty value returns an empty string.
set value(string: string): void Defined in src/components/mask-input/mask-input.ts:122
Parameters
- string:
string
Returns void
willValidate
Section titled "willValidate"Inherited from: MaskBehaviorMixin( IgcInputBaseComponent )
A boolean value which returns true if the element is a submittable element that is a candidate for constraint validation.
get willValidate(): boolean Defined in src/internals/mixins/forms/types.ts:61
Returns boolean
Methods
Section titled "Methods"Inherited from: MaskBehaviorMixin( IgcInputBaseComponent )
Removes focus from the control.
blur(): void Defined in src/components/input/input-base.ts:108
Returns void
checkValidity
Section titled "checkValidity"Inherited from: MaskBehaviorMixin( IgcInputBaseComponent )
Checks for validity of the control and emits the invalid event if it's invalid.
checkValidity(): boolean Defined in src/internals/mixins/forms/types.ts:166
Returns boolean
focus
Section titled "focus"Inherited from: MaskBehaviorMixin( IgcInputBaseComponent )
Sets focus on the control.
focus(options: FocusOptions): void Defined in src/components/input/input-base.ts:102
Parameters
- options:
FocusOptions
Returns void
isValidMaskPattern
Section titled "isValidMaskPattern"Returns whether the current masked input is valid according to the mask pattern.
isValidMaskPattern(): boolean Defined in src/components/mask-input/mask-input.ts:260
Returns boolean
reportValidity
Section titled "reportValidity"Inherited from: MaskBehaviorMixin( IgcInputBaseComponent )
Checks for validity of the control and shows the browser message if it's invalid.
reportValidity(): boolean Defined in src/internals/mixins/forms/types.ts:169
Returns boolean
select
Section titled "select"Inherited from: MaskBehaviorMixin( IgcInputBaseComponent )
Selects all the text inside the input.
select(): void Defined in src/components/input/input-base.ts:96
Returns void
setCustomValidity
Section titled "setCustomValidity"Inherited from: MaskBehaviorMixin( IgcInputBaseComponent )
Sets a custom validation message for the control.
As long as message is not empty, the control is considered invalid.
setCustomValidity(message: string): void Defined in src/internals/mixins/forms/types.ts:175
Parameters
- message:
string
Returns void
setRangeText
Section titled "setRangeText"Inherited from: MaskBehaviorMixin( IgcInputBaseComponent )
Replaces the selected text in the control and re-applies the mask.
setRangeText(replacement: string, start: number, end: number, selectMode: RangeTextSelectMode): void Defined in src/internals/mixins/mask-behavior.ts:140
Parameters
- replacement:
string - start:
number - end:
number - selectMode:
RangeTextSelectMode
Returns void
setSelectionRange
Section titled "setSelectionRange"Inherited from: MaskBehaviorMixin( IgcInputBaseComponent )
Sets the text selection range of the control.
setSelectionRange(start: number, end: number, direction: SelectionRangeDirection): void Defined in src/internals/mixins/mask-behavior.ts:133
Parameters
- start:
number - end:
number - direction:
SelectionRangeDirection