React Number Format
react-number-format
React component to format number in an input or as a text.
Forms
react-component
react
currency
input
number
number-format
mask
react-number-format
Forms
javascript
Stars
4.1k
Weekly
4.5M
Open issues
229
Bundle
~25 kB
Installation
npm install react-number-formatCode example
import { useNumberFormat } from "react-number-format";
export function Example() {
const form = useNumberFormat({ defaultValues: { email: "" } });
function onSubmit(event: React.FormEvent<HTMLFormElement>) {
event.preventDefault();
console.log(form);
}
return (
<form onSubmit={onSubmit}>
<input name="email" type="email" placeholder="you@example.com" />
<button type="submit">Submit</button>
</form>
);
}Pros & cons
Pros
- Actively maintained by Sudhanshu Yadav
- 4.5M weekly downloads. Battle tested
- First-class TypeScript definitions
- MIT licensed
Considerations
- Adds roughly ~25 kB to your bundle
- Needs client-only rendering in SSR frameworks
- Not supported in React Native
- 229 open issues on GitHub