
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
input-masked-react
Advanced tools
A fully customizable masked input component for the web built with React
A fully customizable masked input component for the web built with React. Inspired by devfolioco/react-otp-input


yarn add input-masked-react
import React from 'react';
import MaskedInput from 'input-masked-react';
const App = props =>
<MaskedInput
numInputs={4}
onChange={otp => console.log(otp)}
separator={<span> </span>}
/>
import React from 'react';
import MaskedInput from 'input-masked-react';
const App = props =>
<MaskedInput
numInputs={4}
onChange={otp => console.log(otp)}
inputStyle={{
border: 0,
borderBottom: "1px solid #DFE0E3",
width: 20,
height: 30
}}
/>
import React from 'react';
import MaskedInput from 'input-masked-react';
const App = props =>
<MaskedInput
numInputs={4}
onChange={otp => console.log(otp)}
isDisabled
disabledStyle={{
background: 'red'
}}
/>
import React from 'react';
import MaskedInput from 'input-masked-react';
const App = props =>
<MaskedInput
numInputs={4}
onChange={otp => console.log(otp)}
isNumeric
/>
import React from 'react';
import MaskedInput from 'input-masked-react';
const App = props =>
<MaskedInput
numInputs={4}
onChange={otp => console.log(otp)}
focusStyle={{
outline: 0
}}
/>
import React from 'react';
import MaskedInput from 'input-masked-react';
const App = props =>
<MaskedInput
numInputs={4}
onChange={otp => console.log(otp)}
inputStyle={{
border: 0,
borderBottom: "1px solid #DFE0E3",
width: 20,
height: 30
}}
placeholder='Y'
/>
import React from 'react';
import MaskedInput from 'input-masked-react';
const App = props =>
<MaskedInput
numInputs={8}
onChange={otp => console.log(otp)}
inputStyle={{
border: 0,
borderBottom: "1px solid #DFE0E3",
width: 20,
height: 30
}}
placeholder='Y'
groupSeparatorPositions={[1, 3]}
groupSeparator={<div style={{ width: 15 }} />}
/>
import React from 'react';
import MaskedInput from 'input-masked-react';
const App = props =>
<MaskedInput
numInputs={8}
onChange={otp => console.log(otp)}
inputStyle={{
border: 0,
borderBottom: "1px solid #DFE0E3",
width: 20,
height: 30
}}
inputPropsMap={{
0: { placeholder: "D", style: { width: 30 } },
1: { placeholder: "D" },
2: { placeholder: "M" },
3: { placeholder: "M" },
4: { placeholder: "Y" },
5: { placeholder: "Y" },
6: { placeholder: "Y" },
7: { placeholder: "Y" },
}}
groupSeparatorPositions={[1, 3]}
groupSeparator={<div style={{ width: 15 }} />}
/>
import React from 'react';
import MaskedInput from 'input-masked-react';
const App = props =>
<MaskedInput
numInputs={4}
onChange={otp => console.log(otp)}
inputStyle={{
border: 0,
borderBottom: "1px solid #DFE0E3",
width: 20,
height: 30
}}
error
errorText={
<div style={{ color: "red", marginTop: 10 }}>
An error has occured!
</div>
}
/>
import React from 'react';
import MaskedInput from 'input-masked-react';
const App = props =>
<MaskedInput
numInputs={4}
onChange={otp => console.log(otp)}
inputStyle={{
border: 0,
borderBottom: "1px solid #DFE0E3",
width: 20,
height: 30
}}
defaultValues={'1000'.split('')}
/>
import React from 'react';
import MaskedInput from 'input-masked-react';
const App = props =>
<MaskedInput
numInputs={4}
onChange={otp => console.log(otp)}
inputStyle={{
border: 0,
borderBottom: "1px solid #DFE0E3",
width: 20,
height: 30
}}
valueEnteredStyle={{
borderBottom: '2px solid blue'
}}
focusStyle={{
outline: 0
}}
/>
import React from 'react';
import MaskedInput from 'input-masked-react';
const App = props =>
<MaskedInput
numInputs={8}
inputStyle={{
border: 0,
borderBottom: "1px solid #DFE0E3",
width: 20,
height: 30
}}
inputPropsMap={{
0: { placeholder: "D" },
1: { placeholder: "D" },
2: { placeholder: "M" },
3: { placeholder: "M" },
4: { placeholder: "Y" },
5: { placeholder: "Y" },
6: { placeholder: "Y" },
7: { placeholder: "Y" }
}}
groupSeparatorPositions={[1, 3]}
groupSeparator={<div style={{ width: 15 }} />}
onChange={data => console.log(data)}
/>
import React from 'react';
import MaskedInput from 'input-masked-react';
const App = props =>
<MaskedInput
numInputs={4}
inputStyle={{
border: 0,
borderBottom: "1px solid #DFE0E3",
width: 20,
height: 30
}}
separator={<span> </span>}
placeholder={"•"}
onChange={data => console.log(data)}
/>
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| numInputs | number | true | 4 | Number of OTP inputs to be rendered. |
| onChange | function | true | console.log | Returns OTP code typed in inputs. |
| separator | component | false | [space] | Provide a custom separator between inputs by passing a component. For instance, <span>-</span> would add - between each input |
| containerStyle | style (object) / className (string) | false | none | Style applied or class passed to container of inputs. |
| inputStyle | style (object) / className (string) | false | none | Style applied or class passed to each input. |
| focusStyle | style (object) / className (string) | false | none | Style applied or class passed to inputs on focus. |
| isDisabled | boolean | false | false | Disables all the inputs. |
| disabledStyle | style (object) / className (string) | false | none | Style applied or class passed to each input when disabled. |
| error | boolean | false | false | Indicates there is an error in the inputs. |
| errorStyle | style (object) / className (string) | false | none | Style applied or class passed to each input when errored. |
| shouldAutoFocus | boolean | false | false | Auto focuses input on inital page load. |
| isInputNum | boolean | false | false | Restrict input to only numbers. |
| placeholder | string | false | none | Placeholder for each input |
| errorText | ReactNode | false | none | Error message to show |
| groupSeparator | ReactNode | false | none | React element to show at groupSeparatorPositions |
| groupSeparatorPositions | Object | false | {} | Positions when to show groupSeparator |
| inputPropsMap | Object | false | {} | An object with props specifically for individual inputs |
| defaultValues | Array | false | [] | An array of default values for inputs |
| valueEnteredStyle | Object | false | {} | Styles applied on value-entered inputs |
FAQs
A fully customizable masked input component for the web built with React
The npm package input-masked-react receives a total of 62 weekly downloads. As such, input-masked-react popularity was classified as not popular.
We found that input-masked-react demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.