Methane@methane-ui/*
CSS LayoutsComponentsSkillsTheme BuilderGitHub
← All Components

<mth-phone-input>

@methane-ui/ui~11.2 KB brotli (cold + Lit)~3.8 KB marginal

Form-associated international phone number field combining country dial code selection and cursor-preserving pattern masking via MaskAndFormatEngine.

When NOT to use: Use a lightweight @methane-ui/css layout class instead of a custom element when static CSS suffices.

Live Interactive Preview

Interactive StageLive Custom Element · <mth-phone-input> (@methane-ui/ui)
Ready · interact with <mth-phone-input>, or toggle Theme, Direction (LTR/RTL), or props above.

Multi-Framework Playground & Snippets

<script type="module" src="@methane-ui/ui/phone-input"></script>
<mth-phone-input placeholder="(555) 123-4567" autocomplete="tel-national"></mth-phone-input>

Properties & Attributes

PropertyAttributeTypeDefaultDescription
valuevaluestring""Formatted national phone string.
namenamestring""Form submission field name.
labellabelstring""Accessible label rendered inside shadow root.
hinthintstring""Helper text displayed below control.
errorerrorstring""Explicit custom error message.
placeholderplaceholderstring"(555) 123-4567"Placeholder displayed when empty.
autocompleteautocompletestring"tel-national"HTML autocomplete token (defaults to tel-national).
countrycountrystring"US"ISO 3166-1 alpha-2 country code (e.g. "US", "GB", "DE").
dialCodedial-codestring"+1"International calling prefix (e.g. "+1", "+44").
maskmaskstring"(000) 000-0000"Mask pattern using 0/9 digit tokens or custom # digits.
disableddisabledbooleanfalseDisables interaction.
requiredrequiredbooleanfalseMarks control required.
readonlyreadonlybooleanfalsePrevents edits while allowing focus and submission.

Events

EventDetail TypeDescription
mth-input{ value: string; unmasked: string; dialCode: string; e164: string }Fired synchronously when the phone number updates.
mth-change{ value: string; unmasked: string; dialCode: string; e164: string }Fired when the phone number commits.
mth-country-change{ country: string; dialCode: string }Fired when the country dial code changes.

APG Keyboard Matrix

KeyDirectionWhenExpected Behavior
Enterbothinside a form and not composing IMErequests submission of owning form

Accessibility Checklist

CategoryRequirementVerified By
ariaAll aria-* IDREFs resolve within the same DOM root (ADR-003).scanSameRootAria
focusdelegatesFocus: true with zero host internals.role (ADR-014).lint-plugin & spec-compiler
contrastRenders legible borders, focus outlines, and selection indicators under forced-colors: active.Playwright forced-colors matrix
keyboardImplements all 1 APG keyboard transitions across LTR/RTL.mth-phone-input.spec.test.ts
statesExposes ElementInternals CustomStateSet flags: :state(dirty), :state(touched), :state(user-invalid), :state(disabled), :state(required), :state(readonly).Conformance suite
i18nRoutes 4 UI/ARIA strings through @methane-ui/core i18n catalog.Locale context test