Tax ID Input

Catches mistyped GSTIN, PAN and EU VAT numbers by checking their structure and the GSTIN check character, and pointing at the wrong character.

StopsInvoice sent with a mistyped GSTIN

Installation

pnpm dlx shadcn@latest add https://bollard-ui.vercel.app/r/tax-id-input.json

The files land in your project. They're yours to edit.

Usage

tax-id-input-usage.tsx
import { TaxIdInput } from "@/components/ui/tax-id-input"

<TaxIdInput kind="gstin" label="Supplier GSTIN" defaultValue="27AAPFUO939F1ZV" />

What it catches

  • GSTIN check character that doesn't match (mod-36)
  • Look-alike characters (O/0, I/1) and swapped neighbours
  • State code, PAN holder type and EU country read back
  • EU VAT body shape per country, and GR typed instead of EL
  • Wrong length for the chosen kind

Props

TaxIdInput props
PropTypeDefault
kind* (required)

Which number the field holds.

TaxIdKind—
label

Visible label. Defaults to the kind's name.

stringLABELS[kind]
value

Controlled value, without spaces.

string—
defaultValue

Initial value when uncontrolled.

string""
onValueChange

Called with the cleaned value (no spaces, upper case) and whether it passed every check.

(value: string, valid: boolean) => void—
hint

Helper text shown while there is nothing to report.

string—
locale

Locale for EU country names.

string"en"
messages

Override any of the default messages.

Partial<typeof TAX_ID_MESSAGES>—

* required. Also accepts the native props of <input> (className, aria-*, data-*…), passed through to it.

Accessibility

  • Visible <label>; aria-invalid with status via aria-describedby
  • Status and fixes in a polite live region
  • After a fix, focus returns to the input
  • External verify link has visible text

Only what the source does. Test with your own screen reader and content before shipping.

Limitations

This is a UX guard rail. Enforce on the server: Verify GSTIN/VAT registration with the official service server-side before issuing tax invoices.

  • Format looks valid ≠ registered: it does not confirm the number exists or is active
  • Use the GST portal or VIES to verify registration
  • EU VAT patterns check structure, not national check digits

Rules

Rules not yet verified against an official source.

GSTIN check-character algorithm, GST state codes, PAN 4th-character holder types and EU VAT body patterns were not re-verified against a primary source this round. Informational; verify registration with the GST portal or VIES. Copied components don't update themselves, so re-check after rule changes (see updating a component).

What it stops

Invoice sent with a mistyped GSTIN

Also known as

gstin · gst number · pan · vat number · tax id · invoice · billing · b2b checkout

Field type

Dependencies

Pairs well with