ValyroUI Русская версия

Masked Input

Masked input: cards with Luhn check, expiry, CVC, date, time. Pro · Forms and input › Numbers, codes and masks

Text field that formats input against a mask as you type, keeps the caret next to the character you edited, accepts pasted values, and steps over separators on Backspace. With name, a form submits the text as shown ("4242 4242 …"); the raw value comes from onValueChange.

Installation

npx valyro-cli@latest login
npx valyro-cli@latest add masked-input
npm install valyro-ui-pro

import 'valyro-ui-pro/styles.css';
import { MaskedInput } from 'valyro-ui-pro';

Props

PropTypeDefault
mask *MaskPreset | string | MaskDefinitionA preset (card, expiry, cvc, date, time), a pattern (9 digit, a letter, * either, \ escapes, anything else is a literal), or a full MaskDefinition.
valuestringRaw value: the typed characters without the literals.
defaultValuestring''Initial value when uncontrolled.
onValueChange(value: string, details: MaskedInputDetails) => voidCalled with the new value when it changes.
showCardBrandbooleantrueShow the detected card network at the end of card-number fields (default true).
size'sm' | 'md' | 'lg'Field height and text size.
leftIconReactNodeIcon inside the field, before the text.
rightIconReactNodeIcon inside the field, after the text and the clear/password buttons.
prefixReactNodeAttached text before the input, e.g. "https://".
suffixReactNodeAttached text after the input, e.g. ".vercel.app".
invalidbooleanError border and aria-invalid on the input (an explicit aria-invalid wins).
clearablebooleanShows a clear button while the input has a value.
labelsPartial<TextInputLabels>Accessible names of the clear and show/hide password buttons.

Related components

Previous: Phone Input · Next: Date Picker · All Forms and input