Skip to content

rafaelguinho/cpf-cnpj-input

Repository files navigation

react-cpf-cnpj-input-field

A React input component with dynamic mask for Brazilian CPF or CNPJ documents

NPM

Table of Contents

Install

npm install --save react-cpf-cnpj-input-field

Usage

import React from 'react'

import CpfCnpjInput from 'react-cpf-cnpj-input-field'

const App = () => {
  render() {
    return <CpfCnpjInput />
  }
}

Usage with React Hook Form

<Controller
  control={control}
  name='cpf_cnpj'
  render={({ field: { onChange, onBlur, value, name } }) => (
    <CpfCnpjInput
      onBlur={onBlur}
      onChange={onChange}
      checked={value}
      name={name}
    />
  )}
/>

Properties

Name Description Default
style Custom styles undefined
alwaysShowMask Define whether to always show the mask false
defaultMaskType Accepted ("CPF", "CNPJ") "CPF"
as You can provide a custom input undefined

License

MIT © rafaelguinho

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published