MaskInput
Input with mask pattern for formatted text entry
Source
LLM docs
Docs
Package
Usage
MaskInput is a wrapper around useMask hook that provides all standard input
props (label, description, error, etc.) and supports all mask options. The mask string defines
the expected format using token characters (9 for digits, a for letters, etc.).
Input description
Dynamic mask
Use the modify option to change the mask based on the current input value.
This example switches between standard and American Express credit card formats:
Custom tokens
Override or extend the built-in token map with the tokens option:
Regex array format
For complex masks where built-in tokens are not enough, pass an array of
string literals and RegExp objects:
Transform
Use the transform option to convert each character before validation.
This example auto-uppercases input so the A token accepts lowercase letters:
Type lowercase letters – they will be auto-uppercased
Disabled state
Error state
Invalid phone number
Mask pattern syntax
The mask string defines the expected format. Each character is either a token (editable slot) or a literal (fixed character inserted automatically).
Built-in tokens
9– any single digit ([0-9])a– any single letter ([A-Za-z])A– any uppercase letter ([A-Z])*– any alphanumeric character ([A-Za-z0-9])#– digit or sign ([-+0-9])
Optional segments
Append ? after the last required character to mark remaining slots as optional:
Escaping
Prefix a token character with \ to treat it as a literal: