Copy-paste

Recipes

Production-ready PhoneField patterns composed from the same primitives and shadcn components used by the playground.

Basics

Inline country select

defaultshadcn

One visual field with separate accessible country and phone controls.

Best for settings, profiles, and compact forms.

Use when

Use this as the default for profiles, contact forms, and account settings.

Requires

field · input-group

Accessibility

Country and phone keep independent names while sharing one visual boundary.

Separated country select

checkoutresponsive

Country and phone retain their own visual boundaries for dense forms.

Use when

Use it when labels and column alignment matter more than compactness.

Requires

field · input

Accessibility

Each control has its own visible label and focus target.

Fixed country

single marketsimple

Remove the picker when the product already knows the supported market.

Fixed region
+1

No country picker when the market is already known.

Use when

Use it for market-specific products or tenant-level country policies.

Requires

field · input-group

Accessibility

The dialing code remains visible even though it is not interactive.

Phone with extension

businessextension

Collect an office extension without mixing it into the canonical phone value.

+1
ext.

Keep the extension separate from the canonical E.164 phone value.

Use when

Use it for business contacts, support desks, and PBX-backed phone records.

Requires

field · input-group

Accessibility

Phone and extension have independent labels, values, and input modes.

Forms

Validated field

fieldvalidation

Real-time required and invalid states with accessible error messaging.

Used for delivery updates.

Use when

Use it in controlled forms that own validation without a form library.

Requires

field · input-group

Accessibility

Errors are connected with aria-describedby and exposed through aria-invalid.

Server-safe FormData

server actionnative

Submit minimal source values and rebuild trusted derived data at the boundary.

FormData → canonical value

Use when

Use it for native forms, server actions, or progressively enhanced submissions.

Requires

field · input-group

Accessibility

The visible field remains native while hidden source inputs serialize the value.

React Hook Form + Zod

rhfzod

Controller-based integration with Standard Schema validation on every change.

+1

React Hook Form + Zod

Use when

Use it when React Hook Form owns the complete form state and submission lifecycle.

Requires

react-hook-form · @hookform/resolvers · zod · field · input-group

Accessibility

Controller forwards blur, value changes, invalid state, and the Zod message.

TanStack Form + Zod

tanstackzod

Type-safe field composition using TanStack Form's Standard Schema support.

+1

TanStack Form + Zod

Use when

Use it for deeply typed or highly reactive forms built around TanStack's ecosystem.

Requires

@tanstack/react-form · zod · field · input-group

Accessibility

Field meta drives real-time aria-invalid and a colocated error announcement.

Disabled, read-only, and loading

statesa11y

Production states that preserve visual structure and communicate availability.

+1
+1
+1

Use when

Use these patterns for permissions, persisted values, and async mutations.

Requires

field · input-group

Accessibility

Native disabled/readOnly semantics are paired with visible status affordances.

Product flows

Phone verification flow

otpmulti-step

A complete phone-to-OTP interaction with editable and verified states.

+1

Use when

Use it for sign-in, onboarding, account recovery, and phone verification.

Requires

button · card · field · input-group · input-otp

Accessibility

Each step exposes a single task, preserves the phone value, and labels the OTP slots.

International paste detection

pastee.164

Pasting an international number updates country and normalized output.

+1

The country updates from a pasted + prefix.

Use when

Use it when users frequently paste numbers from contacts, CRMs, or messages.

Requires

field · input-group

Accessibility

Country changes are reflected in visible text, not communicated by flag alone.

Mobile & localization

Localized country subset

i18nsubset

Limit supported markets and localize country names, search, and sorting.

Lista acotada y nombres localizados en español.

Use when

Use it when product availability is restricted to a known set of countries.

Requires

field · input-group

Accessibility

Localized names remain searchable and visible beside their dialing codes.

Country select in a Drawer

drawermobile

A thumb-friendly country picker designed for mobile product flows.

A thumb-friendly country picker for mobile flows.

Use when

Use it on mobile-first forms where a popover would feel cramped or hard to scan.

Requires

button · drawer · field · input · input-group

Accessibility

The trigger names its purpose and the modal drawer keeps search and options reachable.