Bangladesh
Phone input
+880 mobile numbers typed any way, Bangla digits too; names the operator and gives back +8801XXXXXXXXX.
Type it any way: 017…, +880 17…, or in Bangla digits.
Try 012: no operator uses it.
"use client";
import { type BdPhone, FormField, PhoneInput } from "@waveinno/ui";
import * as React from "react";
export default function PhoneDemo() {
const [phone, setPhone] = React.useState<BdPhone | null>(null);
return (
<div className="grid gap-6 md:grid-cols-2">
<FormField label="Mobile number" hint={phone?.valid ? `Saved as ${phone.e164}` : "Type it any way: 017…, +880 17…, or in Bangla digits."}>
<PhoneInput defaultValue="01712345678" onValueChange={(_, p) => setPhone(p)} />
</FormField>
<FormField label="Empty, with a wrong prefix as you type" hint="Try 012: no operator uses it.">
<PhoneInput />
</FormField>
</div>
);
}Examples#
Each one on its own: copy its code into your app, or copy it to Figma and paste it on the canvas as layers.
With validation
Typed any way; the hint shows the number as it will be stored.
Type it any way: 017…, +880 17…, or in Bangla digits.
"use client";
import { type BdPhone, FormField, PhoneInput } from "@waveinno/ui";
import * as React from "react";
export default function PhoneValidatedExample() {
const [phone, setPhone] = React.useState<BdPhone | null>(null);
return (
<div className="w-full max-w-sm">
<FormField label="Mobile number" hint={phone?.valid ? `Saved as ${phone.e164}` : "Type it any way: 017…, +880 17…, or in Bangla digits."}>
<PhoneInput defaultValue="01712345678" onValueChange={(_, p) => setPhone(p)} />
</FormField>
</div>
);
}Empty
Start typing: it names the operator, or says a prefix is not used.
Try 012: no operator uses it.
"use client";
import { FormField, PhoneInput } from "@waveinno/ui";
export default function PhoneInputEmptyExample() {
return (
<div className="w-full max-w-sm"><FormField label="Mobile number" hint="Try 012: no operator uses it."><PhoneInput /></FormField></div>
);
}Bangla digits
Bangla digits work too and come back as English ones.
"use client";
import { FormField, PhoneInput } from "@waveinno/ui";
export default function PhoneInputBanglaDigitsExample() {
return (
<div className="w-full max-w-sm"><FormField label="মোবাইল নম্বর"><PhoneInput defaultValue="০১৯১২৩৪৫৬৭৮" /></FormField></div>
);
}Animated#
Motion that earns its place: free ones to copy now, and Pro ones whose code and Figma copy come with a Wavi Pro licence. They respect the visitor's reduced-motion setting.
Phone and one-time code Pro
Sign-in in two steps: the code boxes fill as you type and the resend timer counts down.
Sign in with your phone
This example's code comes with Wavi Pro
One payment for every Pro component, block and template, with every update.
Import#
Everything comes from the package root. The example above uses:
import { type BdPhone, FormField, PhoneInput } from "@waveinno/ui";Props#
Read from the source of this version, so they match the code exactly.
<PhoneInput>
src/components/ui/phone-input.tsx| Prop | Type | Default | Description |
|---|---|---|---|
value | string | — | Any form of the number; "+8801712345678" is what you get back. |
defaultValue | string | "" | |
onValueChange | (e164: string, phone: BdPhone) => void | — | |
showOperator | boolean | true | Show the operator on the right as you type. Default true. |
state | InputState | "default" | |
labels | { invalidPrefix?: string } | — |
Also takes Omit<React.InputHTMLAttributes<HTMLInputElement>, "value" | "defaultValue" | "onChange" | "type">.
<FormField>
src/components/ui/form-field.tsx| Prop | Type | Default | Description |
|---|---|---|---|
label | React.ReactNode | — | |
htmlFor | string | — | The control's id, so clicking the label focuses it. |
required | boolean | — | |
hint | React.ReactNode | — | |
error | React.ReactNode | — | |
warning | React.ReactNode | — | |
success | React.ReactNode | — | |
count | { value: number; max: number } | — | Character counter, e.g. { value: note.length, max: 240 }. |
className | string | — | |
childrenrequired | React.ReactNode | — |
Install#
If the project does not have the package yet, add it, then follow the setup for Next.js or Vite once.
$ npm install @waveinno/ui