PhoneInput
International phone input with country picker, flag emoji and automatic formatting. Outputs an E.164-style string (+CC NNNNNNNN). Exported as PhoneI for back-compat.
Examples
With label
Value: ∅
import { useState } from 'react';import { PhoneInput } from '@kactostecnologia/benix-ds';export default function ContactForm() {const [phone, setPhone] = useState('');return (<PhoneInputlabel="Phone number"requiredvalue={phone}onChange={setPhone}/>);}
Pre-filled with country code
Pass a full E.164 string and the picker auto-selects the matching country.
Value: +5511999998888
import { useState } from 'react';import { PhoneInput } from '@kactostecnologia/benix-ds';export default function EditContact() {const [phone, setPhone] = useState('+5511999998888');return (<PhoneInputlabel="Mobile"value={phone}onChange={setPhone}/>);}
Error state
Phone number is required.
import { PhoneInput } from '@kactostecnologia/benix-ds';export default function ValidatedForm() {return (<PhoneInputlabel="Phone"value=""onChange={() => {}}error="Phone number is required."/>);}
API Reference
Props of the PhoneInput component.
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | — | Full phone with country code, e.g. "+5511999998888". |
onChange | (value: string) => void | — | — |
onBlur | () => void | — | — |
label | string | — | — |
required | boolean | false | — |
error | string | null | — | — |
placeholder | string | 'Digite o número de telefone' | — |
disabled | boolean | false | — |
id | string | — | Optional id (auto-generated otherwise). |