DocsComponentsTemplatesThemesGitHub

PhoneInput

Phone number with a searchable country-code dropdown (search by country or +code) and a tel input.

Code

import * as React from 'react';
import { PhoneInput } from '@fruit-labs/design';

export default function Demo() {
  return (
    <div
      style={{
        maxWidth: 360,
      }}
    >
      <PhoneInput
        label="Mobile number"
        required
        defaultValue="98765 43210"
        hint="We’ll send a code to verify it."
      />
    </div>
  );
}

Install

From npm:

npm install @fruit-labs/design

import { PhoneInput } from '@fruit-labs/design';

Or copy the TypeScript source into your project:

npx shadcn@latest add https://design.fruitlabs.online/r/phone-input.json

Guidelines

  • Default country is India (+91); set defaultCountry. Store country and the national number separately; format to E.164 on the server.
  • Pass your own countries list as [ISO, name, dial] triples.

Props

PropTypeRequired
valuestringNo
defaultValuestringNo
onChange(number: string) => voidNo
countrystringNo
defaultCountrystringNo
onCountryChange(iso: string) => voidNo
countriesArray<[string, string, string]>No
labelstringNo
hintReact.ReactNodeNo
errorReact.ReactNodeNo
requiredbooleanNo
placeholderstringNo
size'sm' | 'md'No
classNamestringNo
styleReact.CSSPropertiesNo

Edit this example on GitHub