Get back to home
2024-03-08

Phone input number component with Shadcn UI

This is a demo of a custom phone number component built with Shadcn UI. Feel free to play around with it and customize it to your needs.

You will need some extra packages to make this works.

Terminal window
npm install libphonenumber-js i18n-iso-countries react-phone-number-input

Don’t forget to register the local you want.

import { registerLocale } from "i18n-iso-countries"
// The local you want
import enCountries from "i18n-iso-countries/langs/en.json"
registerLocale(enCountries)

Archived demo

Phone input demo on StackBlitz

The interactive demo now lives in a dedicated StackBlitz project pinned to the article-era stack, so future site upgrades do not silently rewrite the published example.