Taiwan Phone Input
Mobile numbers starting with 09 are formatted automatically as 09xx-xxx-xxx, with landline and mobile detected automatically.
A Taiwan phone number input: hyphens are inserted as you type (0912-345-678), numbers starting with 09 are detected as mobile and those starting with 0X as landline, grouped by the length of the area code (02-2712-3456). The leading icon switches with the type, an invalid prefix is flagged in red immediately, and pasting a string containing +886, full-width digits, or other noise is cleaned automatically.
npx shadcn@latest add https://webberui.com/r/taiwan-phone-input.jsonPlayground
Tune the props live — the code snippet updates as you go, so you can dial in the look you want before copying it.
<TaiwanPhoneInput />
Installation
npx shadcn@latest add https://webberui.com/r/taiwan-phone-input.jsonOr, once registries are configured in components.json, install it as @webberui/taiwan-phone-input.
Usage
import { TaiwanPhoneInput } from "@/components/ui/taiwan-phone-input";
const [phone, setPhone] = React.useState("");
<TaiwanPhoneInput value={phone} onChange={setPhone} allowLandline />onChange returns the cleaned digits (for example 0912345678), ready to store directly in a database; the hyphenated display format is handled inside the component. You can also use the exported normalizeTaiwanPhone and analyzeTaiwanPhone helper functions to clean and validate outside the component.
The landline area code table includes every current long-distance area code (02–08, 037, 049, 082, 089, 0836), matched longest-area-code-first. Some area codes mix 7- and 8-digit subscriber numbers in practice; the component demonstrates the common length, so extend the built-in lookup table if you need more precision.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | — | Controlled value: the phone number (it may contain noise, which is cleaned to digits internally) |
onChange | (digits: string) => void | — | Fires when the value changes, returning the cleaned digits-only string |
allowLandline | boolean | true | Whether landlines (0X area codes) are accepted; false accepts only mobile numbers starting with 09 |
placeholder | string | depends on allowLandline | Placeholder text |
disabled | boolean | false | Disable the input |
name | string | — | Form field name; the digits are submitted through a hidden field |
id | string | — | The input element's id, for binding an external label |
className | string | — | Forwarded to the outermost container |
Accessibility
- It uses
type="tel",inputMode="tel", andautoComplete="tel", so mobile devices bring up the numeric keypad automatically and autofill works aria-invalidis set when validation fails, and the error and success messages sit in anaria-live="polite"region so they are read out immediately- The decorative type icon and status icon are both marked
aria-hiddenand do not interfere with assistive technology - When the user has "reduce motion" enabled at the system level, the icon switch, the green check pop, and the message expansion animations are disabled
- When editing mid-string, the caret position is restored correctly after reformatting and does not jump to the end of the line
Taiwan Business Tax ID Input (React)
A React component that validates Taiwan's 8-digit business tax ID (統一編號) in real time — it implements the 2023 check-digit algorithm (weights 1,2,1,2,1,2,4,1, including the special case where the 7th digit is 7) and shows pass/fail with animated feedback as you type.
E-Invoice Carrier Input (React)
An input for Taiwan's common e-invoice carrier (the mobile barcode) — it validates the "leading / plus 7 characters" format and its character set, and draws the carrier number as a Code 39 barcode in real time for scanning.