MaskVisualTransformation
A visual transformation that applies a mask pattern to text input. This class helps format various types of input like card numbers, dates, and phone numbers by inserting special characters at predefined positions while maintaining the original input.
The mask pattern uses '#' to represent input characters and any other character as a literal that will be inserted at that position. The transformation preserves the original input value while displaying it with the specified formatting.
Example:
// Create a mask for a card number (#### #### #### ####)
val cardNumberMask = MaskVisualTransformation("#### #### #### ####")
// Apply the mask to a text field
TextField(
value = text,
onValueChange = { text = it },
visualTransformation = cardNumberMask
)
// Input: "4111111111111111"
// Display: "4111 1111 1111 1111"
Content copied to clipboard
Parameters
mask
The pattern to apply, using '#' for input characters and other characters as literals