Fine-tune light, shadows, borders, neumorphic
Light and shadows
Borders
Neumorphic
Forms Form-associated

PhoneInput <pm-phone-input>

Phone input: a country picker and a telephone field that give one international number.

Full screen

Props

<script type="module"> import '@prismora/css'; import '@prismora/elements/phone-input'; </script> <pm-phone-input label="Mobile number" name="phone" country="GB" hint="We only use it to confirm deliveries." style="inline-size: min(100%, 22rem)"></pm-phone-input> <pm-phone-input label="Office line" value="+14155550123" countries="US,CA,MX" style="inline-size: min(100%, 22rem)"></pm-phone-input>

Sizes

Set with the size attribute; controls keep touch-sized targets on phones.

size="xs"
size="sm"
size="md"
size="lg"
size="xl"

States

Each state is one attribute.

Disabled
Read-only
Required
Error

Overview

value is the number in international form (+14155550123), which is what the form submits; the reader types the national number as they know it, with spaces or dashes if they like. Pasting a number that starts with + sets the country. Country names come from the browser in the page's language. It checks the length (8 to 15 digits with the country code); it does not know each country's numbering plan, so verify the number on your server or by sending a code.

Attributes

AttributeTypeDefaultDescription
countrystring—Selected country as a two-letter code, e.g. GB. Default: the region of the page's or the browser's language, else US.
countriesstring—Offer only these countries, in this order: countries="US,CA,MX".
placeholderstring—Hint text shown while empty (not a replacement for label).
country-label
prop: countryLabel
string—Accessible name of the country picker (default "Country").
autocompletestring—Autofill hint of the number field (default tel-national).
namestring—Form field name: the value is submitted under it.
valuestring—Current value (submitted with the form).
labelstring—Visible label (required for accessibility; use hide-label to visually hide it).
hintstring—Help text under the field, linked to it for screen readers.
errorstring—Custom error message. Setting it marks the control invalid.
size'xs' | 'sm' | 'md' | 'lg' | 'xl'—Control size.
requiredbooleanfalseThe form cannot be submitted until this has a value.
disabledbooleanfalseNot interactive and not submitted.
readonlybooleanfalseFocusable and submitted, but not editable.
hide-label
prop: hideLabel
booleanfalseHide the label visually; it stays the accessible name.

Also accepts the contextual attributes tone, surface, radius, density, motion, elevation. They are inherited from ancestors' data-* attributes.

Events

EventReact / Svelte propDescription
pm-inputonPmInputWhile typing. detail.value (international), detail.country and detail.national.
pm-changeonPmChangeThe number or the country was committed. Same detail.

CSS parts

PartDescription
::part(control)The native telephone input.
::part(country)The country picker.

Methods

checkValidity(), reportValidity(), validate(), focus()

Used in templates

Customer 360