content/docs/components/radix/phone-input.mdx
We used the react-phone-number-input library to create this component.
<ComponentPreview styleName="base-nova" name="c-phone-input-1" className="[&_.preview>*]:w-full [&_.preview>*]:max-w-xs" />
npx shadcn@latest add @reui/phone-input
<Step>Install the following dependencies:</Step>
npm install @base-ui/react react-phone-number-input
<Step>Copy and paste the following code into your project.</Step>
<ComponentSource styleName="base-nova" name="phone-input" title="components/reui/phone-input.tsx" />
</Steps> </TabsContent> </CodeTabs>import { PhoneInput } from "@/components/reui/phone-input"
<PhoneInput
placeholder="Enter phone number"
defaultCountry="US"
value={value}
onChange={setValue}
/>
<ComponentPreview styleName="base-nova" name="c-phone-input-2" className="[&_.preview>*]:w-full [&_.preview>*]:max-w-xs" />
The main component for entering phone numbers with country selection.
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | - | The current phone number value in E.164 format. |
onChange | (value: string) => void | - | Callback fired when the value changes. |
variant | "sm" | "default" | "lg" | "default" | The vertical size of the input and country selector. |
popupClassName | string | - | Additional CSS classes for the country selection dropdown. |
defaultCountry | Country | - | The default country selected if no value is provided. |
placeholder | string | - | Placeholder text for the phone number input. |
className | string | - | Additional CSS classes for the root container. |
disabled | boolean | false | Whether the input and country selector are disabled. |
This component also accepts all props from the react-phone-number-input library.