Skip to content
Inputs

Phone Input

A phone field that stores E.164 and lets people type a national number.

Walkthrough

1. Basic

The value is stored as E.164 and typed as a national number, so nobody has to type the dial code and nobody can mistype it.

Stored as +9647701234567

<script lang="ts">	import { PhoneInput } from 'omaris';โ€‹	let phone = $state('+9647701234567');</script>โ€‹<div class="flex w-80 max-w-full flex-col gap-2">	<PhoneInput label="Mobile" bind:value={phone} />	<p class="text-body-sm text-muted-foreground">		Stored as <code class="text-foreground">{phone || '(empty)'}</code>	</p></div>

2. Pasting and validation

Pasting a full international number switches the country and keeps the digits โ€” +90 โ€ฆ, 0090 โ€ฆ and 00964 โ€ฆ all work. validate shows the incomplete message on blur.

Anything goes.
<script lang="ts">	import { PhoneInput } from 'omaris';โ€‹	let a = $state('');	let b = $state('');</script>โ€‹<PhoneInput class="w-72 max-w-full" label="Try pasting +90 532 123 4567" bind:value={a} /><PhoneInput	class="w-72 max-w-full"	label="Without validation"	validate={false}	bind:value={b}	supportingText="Anything goes."/>