U.S. flagA digital services project by Flexion

Input Mask

formUSWDS-derivedinteractive

Formatted input overlay showing the expected pattern (phone, SSN, zip+4).

Reference: USWDS documentation ↗

Variants

Phone Input Mask

SSNInput Mask

Zip Input Mask

Contract

Class mapping

USWDSFlexNotes
usa-input-masking<flex-input-mask> (custom element)Container element with data-mask attribute
usa-masked.flex-input-mask__inputInput element with transparent background
usa-input-masking__content (overlay).flex-input-mask__overlayOverlay showing remaining mask characters

Verified properties

background-colorfont-sizefont-family

Intentional differences

background-color: ours = transparent, USWDS = transparent

Both use transparent background on the input so the overlay shows through

position: ours = relative, USWDS = static

We use position: relative + z-index to stack the input above the overlay span; USWDS uses a different overlay approach

Behavior promises

  • ✓ Typing digits formats according to phone mask
  • ✓ Typing digits formats according to SSN mask
  • ✓ Overlay updates to show remaining mask characters
  • ✓ Non-digit keys are rejected for numeric masks
  • ✓ Pasting a value formats correctly
  • ✓ Accessibility audit passes

Source CSS

Base styles: Form Control Base