PhoneInput
Un número de teléfono con su país. El valor es internacional (+573001234567), así sirve para llamadas y mensajes en cualquier lugar.
import { PhoneInput } from '@sypnia/ui/react'
En esta página
Un número para alertas
Saved as +573001234567
Código
import { useState } from 'react';
import { Field, PhoneInput } from '@sypnia/ui/react';
// The country and the number; the value is international, ready for calls and messages.
export default function Contact() {
const [phone, setPhone] = useState('+573001234567');
return <Field label="Phone for alerts" hint={`Saved as ${phone || '—'}`}><PhoneInput value={phone} onChange={setPhone} /></Field>;
} Cuándo usarlo
Úsalo cuando
- Números para alertas, WhatsApp o soporte.
No lo uses cuando
- Texto libre para números: se pierde el país.
Para todos
- El país y el número son dos controles con nombre; en celulares se abre el teclado de teléfono.
Props
| PhoneInput | Tipo | Por defecto |
|---|---|---|
onChangeobligatorio | (e164: string) => void | |
valueobligatorio | string | |
aria-describedby | string | |
aria-labelThe name for screen readers when there is no Field around it. | string | |
aria-labelledby | string | |
className | string | |
countries | Country[] | [
{ code: 'CO', name: 'Colombia', dial: '57' }, { code: 'MX', name: 'México', dial: '52' }, { code: 'US', name: 'United States', dial: '1' },
{ code: 'ES', name: 'España', dial: '34' }, { code: 'AR', name: 'Argentina', dial: '54' }, { code: 'CL', name: 'Chile', dial: '56' },
{ code: 'PE', name: 'Perú', dial: '51' }, { code: 'EC', name: 'Ecuador', dial: '593' }, { code: 'BR', name: 'Brasil', dial: '55' },
{ code: 'GB', name: 'United Kingdom', dial: '44' },
] |
defaultCountry | string | CO |
disabled | boolean | |
idInside a Field it comes from the Field. | string | |
invalidMarks the value as wrong. Inside a `<Field error>` it is set for you. | boolean | |
name | string | |
size | "sm" | "md" | "lg" |