react-util-masks
v1.0.1
Published
Mascaras para React
Downloads
3
Maintainers
Readme
React Util Masks
Description
react-util-masks
is a React utility library that provides several mask functions to format strings and numbers. Available masks include CPF, CNPJ, CEP, Telephone, and many others.
Installation
Install the package into your React project using npm:
npm install react-util-masks
Usage
First, import the functions you need from the package:
import { maskCPF, maskCurrencyBRL } from 'react-util-masks';
Then, you can use them in your code. For example, to format a number as CPF:
const cpf = '12345678909';
console.log(maskCPF(cpf)); // Output: 123.456.789-09
And to format a number as a currency in BRL:
const amount = 1234.56;
console.log(maskCurrencyBRL(amount)); // Output: R$ 1.234,56
Available Functions
Here is a list of all available mask functions:
- realPorExtenso(valor: number)
- maskCPF(cpf: string)
- maskRG(rg: string)
- maskCNPJ(cnpj: string)
- maskCEP(cep: string)
- maskOnlyNumber(value: string)
- maskTelefone(phone: string)
- maskDecimalNumber(value: string)
- maskCapitalizeFirstLetter(text: string)
- maskCurrencyBRL(value: number) Check the source code or the tests for details on how each function works.
Contribution
If you found an error or would like to add a new feature, feel free to open an issue or pull request on GitHub.
License
ISC