Trusted by the world’s leading companies
Overview
The React Input Mask is a masked text box component that provides an easy and reliable way to collect user input based on a standard mask. It allows you to capture phone numbers, date values, credit card numbers, and other standard format values.
React Input Mask code example
Easily get started with the React Input Mask using a few simple lines of TSX code, as demonstrated below. Also explore the React Input Mask example, which shows you how to render and configure the Input Mask in React.
import * as ReactDOM from 'react-dom';
import * as React from 'react';
import { MaskedTextBoxComponent } from '@syncfusion/ej2-react-inputs';
import { SampleBase } from '../common/sample-base';
import './sample.css';
export class Default extends SampleBase<{}, {}> {
render() {
return (
<div className='control-pane'>
<div className='control-section'>
<div className="content-wrapper sample-mask">
<div className="control-label">Mobile Number
</div>
<MaskedTextBoxComponent mask='000-000-0000'></MaskedTextBoxComponent>
<div className="control-label">Country ISO Code
</div>
<MaskedTextBoxComponent mask='>LL / LLL'></MaskedTextBoxComponent>
<div className="control-label">D.O.B
</div>
<MaskedTextBoxComponent mask='00/00/0000'></MaskedTextBoxComponent>
<div className="control-label">Product Key
</div>
<MaskedTextBoxComponent mask='>AAAAA-AAAAA-AAAAA-AAAAA'></MaskedTextBoxComponent>
</div>
</div>
</div>
)
}
}Standard masks
The React Input Mask component supports the standard masks listed on MSDN.
Custom masks
Other than the standard mask elements, any custom character also can be a mask element by defining rules for it.
Regular expressions
The mask elements can be regular expressions, which is useful when defining user-specific data such as IP addresses.
Mask input combinations
The React Input Mask component allows different mask combinations based on the standard and custom masks. So, you can form different mask formats based on your application scenarios.

Number mask
From the standard mask elements, form a number mask for capturing any finite-length number to get number inputs such as phone numbers and credit card numbers.

String mask
In the case of a country code or product key input, where the input string requires uppercase characters, the string mask format will enforce this.

Date mask
The mask can form any date format to get similarly formatted date values. This is helpful in getting culture-specific date values by defining the corresponding date mask.
Form support and validation
As a form component, this masked text box component proceeds with the raw format of the captured value when submitting the form.
You can also integrate the form validator plugin to perform any custom validation.
Adornments
The Input Mask control supports custom adornments using the prependTemplate and appendTemplate properties, which allow users to render custom elements like icons, buttons, or dropdowns to enhance user interaction with prefix and suffix elements.

HTML5 input type support
You can create the masked text box component from the HTML5 tel input. It opens the numeric keypad on mobile devices, which is useful for obtaining phone numbers or any other number-only inputs.
Web accessibility
- Fully supports WAI-ARIA accessibility to work with screen readers and assistive devices.
- Follows WAI-ARIA best practices for implementing keyboard interaction.
- FollowsWCAG 2.0 standards in the design of the UI element visuals such as foreground color, background color, line spacing, text, and images.
Developer-friendly APIs
Developers can customize all the UI elements and control the behaviors of the React Input Mask according to the end user’s requirements using its rich set of client-side APIs.
Not sure how to create your first React Input Mask? Our tutorial videos and documentation can help.
I’d love to watch them now I’d love to read it nowDiscover Syncfusion’s Complete React Component Ecosystem
Explore over 145+ React UI components featuring established, production-ready controls and the latest pure React components built natively for modern web app development.
-
React Components
-
Pure React Components
-
SMART COMPONENTSGRIDSDATA VISUALIZATIONDROPDOWNSFILE VIEWERS & EDITORSBUTTONSINTERACTIVE CHATINPUTSNAVIGATIONFORMSNOTIFICATIONS
-
GRIDSDATA VISUALIZATIONNAVIGATIONINPUTSCALENDARSDROPDOWNS
Frequently Asked Questions
Why should you choose the Syncfusion React Input Mask?
The Syncfusion React Input Mask lets you:
- Allow users to enter only valid data through the input mask.
Choose from custom mask formats with regular expressions (regex) to validate application-specific data.
- Validate specific data formats such as phone numbers and date masks with different mask combinations.
Enjoy simple configuration and APIs.
- Render on all modern browsers with ease.
- Utilize a touch-friendly and responsive UI.
Take advantage of expansive learning resources such as demos and documentation to get started quickly with the component.
Where can I find the Syncfusion React Input Mask demo?
You can find our React Input Mask demo here.
Can I download and utilize the Syncfusion React Input Mask for free?
No, this is a commercial product and requires a paid license. However, a free community license is also available for companies and individuals whose organizations have less than $1 million USD in annual gross revenue, 5 or fewer developers, and 10 or fewer total employees.
How do I get started with the Syncfusion React Input Mask?
A good place to start would be our comprehensive getting started documentation.
Our Customers Love Us
Awards
Greatness—it’s one thing to say you have it, but it means more when others recognize it. Syncfusion® is proud to hold the following industry awards.