Mask Controller

Mask Controller is a Stimulus controller for applying a mask to a string in an element.

Attributes

HTML Attributes

These are standard HTML attributes (with no prefix) used by the controller.

data- Attributes

All of these attributes are prefixed with "data-" in the attribute name.

Attribute Element(s) Default Value(s) Description
controller (any)
mask This attribute provides the controller functionality.

data-mask- Attributes

All of these attributes are prefixed with "data-mask-" in the attribute name.

Attribute Element(s) Default Value(s) Description
format (root)
(string) The format to apply to the string. See the imask patterns page for more details.

Events

mask: Events

Event Parameters Description
connected Called any time that the controller is connected.
disconnected Called any time that the controller is disconnected.
applied Called any time that the controller applies a format.

Methods

While it is recommended to use the controller via the attributes listed above, the following methods can be called directly if needed.

Method Returns Arguments Event(s) Description
getFormat (string)

Get the format used by this element.