Skip to main content

Masked Input

Conforms user input to a pre-defined pattern.

Examples

Basic Masked Input

Providing a mask prop will guide the user in their entry. Simple regex patterns define allowed values.

import { MaskedInput } from '@curology/ui-components-web/react/MaskedInput';

<MaskedInput
label="SSN"
mask={[/[1-9]/, /d/, /d/, '-', /d/, /d/, '-', /d/, /d/, /d/, /d/]}
placeholder="123-45-6789"
/>

Controlled Masked Input

Like all form inputs, a MaskedInput can either be uncontrolled, or controlled (by providing a value and onChange listener).

import { MaskedInput } from '@curology/ui-components-web/react/MaskedInput';

<MaskedInput
...
value={someValue}
onChange={(evt, value) => ...}
/>

Props

MaskedInputProps

NameTypeDefault ValueRequiredDescription
All attributes of a <input />
fieldClassNamestringNoA className to apply to the field.
fieldPropsRecord<string, unknown>NoAny props to spread onto the field container.
helperTextReactNodeNoA string or component to display as helper text beneath the input
highlightReactNodeNoHighlighted helper text to display at the bottom of the multiline text input
highlightClassNamestringNoA className to apply to the highlight.
iconEndComponentClass<any, any> | FunctionComponent<any> | ReactElement<any, string | JSXElementConstructor<any>> | ForwardRefExoticComponent<any>NoAn icon to render at the end of the input.
iconStartComponentClass<any, any> | FunctionComponent<any> | ReactElement<any, string | JSXElementConstructor<any>> | ForwardRefExoticComponent<any>NoAn icon to render at the front of the input.
labelReactNodeNoA string or component to display as a label above the input
multilinefalse | truefalseNoShould a textarea be used instead of an input?
onChangeFormControlChangeEventHandlerNoEmit a new value when the input's selected value changes.
resizefalse | truefalseNoCan the textarea be resized?
rowsstring | numberNoHow many rows call should the multiline input be?
state"" | "critical" | "warning" | "success"''NoThe state of the field