Components
PreviousNext

Phone Input

A phone input component that simplifies the phone input.

Kit

Installation

Install the following dependencies:

We use the light-weight (145kB) libphonenumber-js library for the phone number validation.

pnpm add libphonenumber-js

Copy and paste the following code into your project.

components/ui/phone-input.tsx
'use client';

import { cn } from '@kit/shared';
import {
    DropdownMenu,
    DropdownMenuContent,
    DropdownMenuItem,
    DropdownMenuTrigger,
} from '@kit/ui/dropdown-menu';
import { Icon } from '@kit/ui/icon';
Get the Kit
Kit required to see the full code

Update the import paths to match your project setup.

Anatomy

Phone Input component anatomy

Phone Input component anatomy

Usage

import { PhoneInputRoot, PhoneInputBase, PhoneInputFlagMenu } from '@kit/ui/phone-input';
<PhoneInputRoot value={value || ''} onPhoneInputChange={handleChange}>
    <PhoneInputFlagMenu className="bg-muted/50 focus-visible:bg-background" />
    <PhoneInputBase className={cn('max-w-md', value ? 'bg-muted/50 focus-visible:bg-background' : '')} />
</PhoneInputRoot>

Features

  • International zip code suggestions
  • Flag menu
  • Phone number formatting

API Reference

Root

PhoneInputRootProps

PropTypeDefault
value
string
onPhoneInputChange
function
defaultNumber
string
defaultCountryISO
CountryCode
'FR'

Flag Menu

Props: Omit<React.HTMLAttributes<HTMLButtonElement>, 'children' | 'type' | 'role'>

Base

The input component.

Props: React.InputHTMLAttributes<HTMLInputElement>

How is this guide?

Last updated on 10/17/2025