Skip to content

PhoneInput

A phone number with its country. The value is international (+573001234567), so it works for calls and messages anywhere.

import { PhoneInput } from '@sypnia/ui/react'

On this page
  1. A number for alerts
  2. When to use it
  3. For everyone
  4. Props

A number for alerts

Saved as +573001234567

Code
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>;
}

When to use it

Use it when

  • Numbers for alerts, WhatsApp or support.

Do not use it when

  • Free text for numbers: the country is lost.

For everyone

  • The country and the number are two named controls; the phone keyboard opens on phones.

Props

PhoneInputTypeDefault
onChangerequired (e164: string) => void
valuerequired string
aria-describedby string
aria-label

The 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
id

Inside a Field it comes from the Field.

string
invalid

Marks the value as wrong. Inside a `<Field error>` it is set for you.

boolean
name string
size "sm" | "md" | "lg"
  1. A number for alerts
  2. When to use it
  3. For everyone
  4. Props

    Search pages, sections and terms