Forms

Phone input.

Country-aware number entry backed by maintained numbering metadata.

LIVE PREVIEWTry it. It works.

Install the source

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/phone-input.json

Registry setup · Examples · API and behavior · Open the playground

COMPLETE EXAMPLES

Use it in context.

Each example includes its imports, data and state. The preview runs that same source. Include the stylesheet once in your application.

Phone entry with real numbering metadata

Search countries, keep incomplete text editable and submit validated E.164 values. Numbering-plan validation does not verify ownership or send a message.

Keyboard

  • Search the country field and use arrows and Enter to select.
  • Type a national or international number; invalid text stays editable. Escape restores the committed number.

States covered

  • metadata validation
  • canonical E.164
  • country search
  • external native form
  • prevented reset
  • read only and disabled

Install this complete example and its component dependencies.

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/example-phone-country-form.json
Complete source
React / TypeScript
/*!
MIT License

Copyright (c) 2026 Jaison

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
'use client';
import '@bld8/ui/styles.css';
import {useId,useState} from 'react';
import {Button,Checkbox,PhoneInput,UIProvider} from '@bld8/ui';
export default function PhoneForm(){const id=useId(),[prevent,setPrevent]=useState(false),[owned,setOwned]=useState<string|null>('+12025550123'),[reject,setReject]=useState(false),[result,setResult]=useState('No phone submitted.');return <UIProvider><div style={{display:'grid',gap:24,maxWidth:620}}>
<PhoneInput label="Contact phone" name="phone" form={id} required defaultCountry="AU" defaultValue="+61412345678" countries={['AU','US','GB','IN']} hint="National or international numbers; extensions are excluded."/>
<PhoneInput label="Host phone" name="owned" form={id} value={owned} onValueChange={next=>{if(!reject)setOwned(next);}} defaultCountry="US" countries={['AU','US','GB','IN']}/>
<PhoneInput label="Locked phone" name="locked" form={id} defaultValue="+61412345678" readOnly countries={['AU','US']}/>
<PhoneInput label="Disabled phone" name="disabled" form={id} defaultValue="+61412345678" disabled countries={['AU','US']}/>
<Checkbox label="Reject host phone edits" checked={reject} onCheckedChange={setReject}/><Checkbox label="Prevent phone reset" checked={prevent} onCheckedChange={setPrevent}/>
<form id={id} aria-label="Contact details" onReset={event=>{if(prevent)event.preventDefault();}} onSubmit={event=>{event.preventDefault();const data=new FormData(event.currentTarget);setResult('Phone: '+data.get('phone')+' | Owned: '+data.get('owned')+' | Locked: '+data.get('locked')+' | Disabled: '+data.has('disabled'));}}><div style={{display:'flex',gap:12,flexWrap:'wrap'}}><Button type="submit">Read phone values</Button><Button type="reset" variant="secondary">Reset phones</Button><Button variant="ghost" onClick={()=>setOwned(null)}>Clear host phone</Button></div></form><p role="status">{result}</p>
</div></UIProvider>;}

Quick reference

React / TypeScript
<PhoneInput label="Phone" name="phone" defaultCountry="AU" />

In the workspace or ZIP starter, import components from @bld8/ui and include @bld8/ui/styles.css once. Registry installations use your local bld8/ source path. Wrap overlays in UIProvider.

API & behaviour

Searchable countries and actual numbering-plan validation use libphonenumber-js max metadata. Submitted values are E.164; invalid drafts remain editable. Native forms/reset and read-only/disabled contracts are explicit. Extensions and verification services are not included.

PhoneInput

PhoneInput public properties
PropTypeDefault
labelRequiredstring—
classNamestring | undefined—
countriesreadonly CountryCode[] | undefined—
countryCountryCode | undefined—
defaultCountryCountryCode | undefined'AU'
defaultValuestring | null | undefinednull
disabledboolean | undefinedfalse
errorstring | undefined—
formstring | undefined—
hintstring | undefined—
inputRefRef<HTMLInputElement> | undefined—
namestring | undefined—
onBlurFocusEventHandler<HTMLInputElement> | undefined—
onCountryChange((country: PhoneCountryCode) => void) | undefined—
onValueChange((value: string | null) => void) | undefined—
placeholderstring | undefined—
readOnlyboolean | undefinedfalse
requiredboolean | undefinedfalse
valuestring | null | undefined—

PhoneInputProps

PhoneInputProps public properties
PropTypeDefault
labelRequiredstring—
classNamestring | undefined—
countriesreadonly CountryCode[] | undefined—
countryCountryCode | undefined—
defaultCountryCountryCode | undefined—
defaultValuestring | null | undefined—
disabledboolean | undefined—
errorstring | undefined—
formstring | undefined—
hintstring | undefined—
inputRefRef<HTMLInputElement> | undefined—
namestring | undefined—
onBlurFocusEventHandler<HTMLInputElement> | undefined—
onCountryChange((country: PhoneCountryCode) => void) | undefined—
onValueChange((value: string | null) => void) | undefined—
placeholderstring | undefined—
readOnlyboolean | undefined—
requiredboolean | undefined—
valuestring | null | undefined—

PhoneCountryCode

CountryCode

PhoneValue

PhoneValue public properties
PropTypeDefault
internationalRequiredstring—
nationalRequiredstring—
valueRequiredstring—
countryCountryCode | undefined—

Tables come from the public TypeScript declarations. Related types and function parameters are shown alongside their component. A dash means no default is declared at the public function boundary.

Related controls

Notes to self

Test this component with real content, keyboard input and both themes. The example is a starting point; labels, error handling and behaviour still need to fit the application.