Skip to main content
196

Search Lumen

Find components, APIs, guides, and recipes.

GitHub
Web docs
Forms

PhoneInput

Combines localized country metadata, calling codes, formatting, validation, and E.164 output.

FrameworksAstro · React · Elements

Registry commandlumen add PhoneInput

InteractionNative markup

01

See it and copy it

Framework example

Choose Astro, React, or Elements to compare native usage against the shared visual output. Each example assumes the framework-level setup is already complete.

AstroCode target · live preview uses Astro
Check this contact number.
+576015550123
View PhoneInput code

Framework usage

Switch targets to compare the adapter code. This live preview runs the Astro example. React and Elements use their own behavior APIs; complete the matching framework setup before copying an example.
astro
---
import { Label, PhoneInput, PhoneNumber } from '@santi020k/lumen-astro'
import { getLumenPhoneCountry, resolveLumenPhoneNumber } from '@santi020k/lumen-core'

const colombia = getLumenPhoneCountry('CO', { locale: 'en-US' })

if (!colombia) throw new Error('Missing Colombia phone metadata')

const contact = resolveLumenPhoneNumber(colombia, '+576015550123')
---

<div style="display: grid; gap: 1rem; width: 100%; max-width: 24rem;">
  <div>
    <Label for="ex-phone">Phone number</Label>
    <PhoneInput countryValue="CO" id="ex-phone" name="phone" placeholder="601 5550123" locale="en-US" required />
  </div>
  <div>
    <Label for="ex-phone-sm">Small</Label>
    <PhoneInput countryValue="GB" id="ex-phone-sm" name="phone-sm" placeholder="Mobile number" visualSize="sm" />
  </div>
  <div>
    <Label for="ex-phone-lg">Large</Label>
    <PhoneInput countryValue="ES" id="ex-phone-lg" name="phone-lg" placeholder="Work number" visualSize="lg" value="612345678" />
  </div>
  <div>
    <Label for="ex-phone-disabled">Disabled</Label>
    <PhoneInput countryValue="CO" disabled id="ex-phone-disabled" name="phone-disabled" value="6015550123" />
  </div>
  <div>
    <Label for="ex-phone-readonly">Read only</Label>
    <PhoneInput countryValue="CO" id="ex-phone-readonly" name="phone-readonly" readOnly value="6015550123" />
  </div>
  <div>
    <Label for="ex-phone-error">Field error</Label>
    <PhoneInput countryValue="CO" errorMessage="Check this contact number." id="ex-phone-error" name="phone-error" value="601" />
  </div>
  <PhoneNumber value={contact} link />
</div>
Edit PhoneInput in browser

Framework differences

React: Use defaultCountryValue and defaultValue for initial values. Controlled value and onValueChange use the structured LumenPhoneNumber contract.

02

Choose your target

Add this component

Choose the package for your runtime. All adapters share the Lumen stylesheet. Use the matching registry command when you want a local wrapper for that framework.

bash@santi020k/lumen-astro
pnpm add @santi020k/lumen-astro
pnpm add @santi020k/lumen-astro
bashAstro wrapper
lumen add PhoneInput
lumen add PhoneInput

API reference

Lumen-specific props and runtime attributes for the Astro primitive. Use the framework differences above and the copyable examples for React composition and Elements attributes; the public adapter types define their supported contracts.

AttributeValuesDefaultDescription
id / input-idstringGeneratedAssociates a visible label with the number input; Web Components use input-id.
inputPropsinput attributes-Passes native number-input attributes without DOM patches.
inputRefReact ref-Exposes the native number-input ref.
disabled / readOnly / requiredbooleanfalseLocks both controls when disabled or read-only and supports native required validation.
errorMessage / showValidationErrorstring / boolean- / trueShows an associated field error or metadata validation feedback.
countriesArray<string | { label, value, disabled? }>International metadataOverrides the generated country choices for legacy or specialized forms.
countryOptionsLumenPhoneCountry[]Generated metadataOverrides localized country metadata while retaining formatting and E.164 behavior.
countryNamestring"country"Sets the name of the country dial-code select.
countryLabelstring"Country code"Sets the accessible label for the dial-code select.
countryValueISO region or calling code"US"Selects the initial country by region or calling code.
localestring | string[]Runtime localeLocalizes generated country names.
namestring"phone"Sets the name of the telephone number input.
placeholderstring"Phone number"Sets the placeholder for the number input.
valuestring (Astro / Elements) | LumenPhoneNumber (React)UncontrolledSets the national input value; React accepts the structured phone-number contract.
onValueChange(value: LumenPhoneNumber) => void-Receives formatting, validity, and E.164 changes in React.
size"default" | "sm" | "lg""default"Controls the height and font size of both controls.
class, classNamestring""Merges custom classes with the generated ui-* root classes.
...native attributesHTML attributes-Forwards standard attributes to the root element unless the component consumes them.

Web docsFull catalog