Components/CPF / CNPJ Input

CPF / CNPJ Input

Brazilian document field with dynamic CPF/CNPJ mask and real check-digit validation. Auto-detects type based on length.


Installation

npx @ajax-ui/cli add cpf-cnpj-input

Props

  • value - raw digits only, no mask. Set both value and onValueChange for controlled.
  • onValueChange(digits, status, type) - fires with the resolved type and validation status.
  • type "auto" | "cpf" | "cnpj" - auto flips at 12 digits.
  • showStatus (default true) - renders the inline ✓ / ✗ badge.

Validation

Both CPF (mod-11 with weights 10→2) and CNPJ (mod-11 with weights 5→2 then 6→2) digit-verifier algorithms are applied. Repeated digits (e.g. 111.111.111-11) are rejected.