
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.
use-mask-input
Advanced tools
A react Hook for build elegant input masks. Compatible with React Hook Form
Input masks for React. Works with React Hook Form, TanStack Form, Ant Design, and plain inputs.
Documentation · API Reference · TanStack Form · Sponsor
npm install use-mask-input
import { useMaskInput } from 'use-mask-input';
function PhoneInput() {
const ref = useMaskInput({ mask: '(99) 99999-9999' });
return <input ref={ref} />;
}
import { useForm } from 'react-hook-form';
import { useHookFormMask } from 'use-mask-input';
function MyForm() {
const { register, handleSubmit } = useForm();
const registerWithMask = useHookFormMask(register);
return (
<form onSubmit={handleSubmit(console.log)}>
<input {...registerWithMask('phone', '(99) 99999-9999')} />
<input {...registerWithMask('email', 'email')} />
<button type="submit">Submit</button>
</form>
);
}
import { useForm } from '@tanstack/react-form';
import { useTanStackFormMask } from 'use-mask-input';
function MyForm() {
const maskField = useTanStackFormMask();
const form = useForm({
defaultValues: {
phone: '',
},
onSubmit: async ({ value }) => {
console.log(value);
},
});
return (
<form
onSubmit={(event) => {
event.preventDefault();
event.stopPropagation();
void form.handleSubmit();
}}
>
<form.Field name="phone">
{(field) => {
const inputProps = maskField(
'(99) 99999-9999',
{
name: field.name,
value: field.state.value,
onBlur: field.handleBlur,
onChange: (event) => field.handleChange(event.target.value),
},
);
return <input {...inputProps} placeholder="(00) 00000-0000" />;
}}
</form.Field>
</form>
);
}
import { Input } from 'antd';
import { useMaskInputAntd } from 'use-mask-input/antd';
function EmailInput() {
const ref = useMaskInputAntd({ mask: 'email' });
return <Input ref={ref} />;
}
| API | Description |
|---|---|
useMaskInput | Hook. Returns a ref callback. Default choice. |
useHookFormMask | Hook. Wraps React Hook Form's register. |
useTanStackFormMask | Hook. Adds mask to TanStack Form field input props. |
withMask | Function. Ref callback. Requires React.memo. |
withHookFormMask | Function. Mask for registered fields. Requires React.memo. |
withTanStackFormMask | Function. Mask for TanStack input props. Requires React.memo. |
useMaskInputAntd | Hook. useMaskInput for Ant Design. |
useHookFormMaskAntd | Hook. useHookFormMask for Ant Design. |
cpf · cnpj · br-bank-account · br-bank-agency · currency · brl-currency · datetime · email · numeric · decimal · integer · percentage · url · ip · mac · ssn
useTanStackFormMask, withTanStackFormMask). See the TanStack Form guide.use-mask-input/antd)MIT
FAQs
A react Hook for build elegant input masks. Compatible with React Hook Form
The npm package use-mask-input receives a total of 60,957 weekly downloads. As such, use-mask-input popularity was classified as popular.
We found that use-mask-input demonstrated a healthy version release cadence and project activity because the last version was released less than 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.