Phone input

Phone input is a neobrutalist React component from Cruise UI. A Nigerian mobile number with a +234 block: shows 0801 234 5678, gives back +2348012345678. Install it with npx shadcn@latest add @cruiseui/phone-input.

Install

Terminal

npx shadcn@latest add @cruiseui/phone-input

First time? Installation shows the one-off components.json setup (the @cruiseui registry) and how to turn the theme on.

Example

Corners

We'll text your order updates here.

Value: not a valid number yet

When to use it

When to use

Asking for a Nigerian mobile number (SMS, delivery, WhatsApp).

When not to

International numbers from any country (use an Input with type="tel").

Props

CruisePhoneInput

PropTypeDefaultDescription
label?string—Visible label. Leave out inside a CruiseFormField (it brings the label).
hint?string——
error?string—Your own error; "not a valid number" is added for you.
defaultValue?string""Any form ("0801…", "+234…"); shown as "0801 234 5678".
onValueChange?((e164: string | null) => void)—The number in E.164 (+2348012345678), or null while it isn't valid.
onValidate?((message: string | undefined) => void)—Called with the validation message (or undefined) after the field is left.

Also takes every native <input> attribute.

Accessibility

  • inputMode="tel" and autocomplete="tel" so phones offer the saved number.
  • The +234 block is decorative; the label names the field.
  • Invalid numbers get a message in words after leaving the field.