Officina UI
Components

MaskedInput

Text input that formats entry against a mask of digit, letter, and literal tokens.

MaskedInput formats what the user types against a mask pattern. The tokens are 9 (digit), a (letter), and * (alphanumeric); any other character is a literal that gets inserted automatically. It is fully controlled — value holds the already-masked string — and is handy for dates, phone numbers, or codes.

Example

Preview
import { MaskedInput } from '@officina/ui';
import { useState } from 'react';

function Example() {
  const [value, setValue] = useState('');
  return <MaskedInput mask="(999) 999-9999" label="Phone" value={value} onChange={setValue} />;
}

API

PropTypeDefaultDescription
mask*string—Mask pattern; `9` = digit, `a` = letter, `*` = alphanumeric (e.g. "(999) 999-9999").
onChange*(value: string) => void—Called with the masked value on input.
value*string—Current (masked) value.
disabledboolean—
invalidboolean—Mark the field invalid for validation styling.
labelstring—Visible label above the field.
namestring—
placeholderstring—
requiredboolean—

On this page