← All Components
<mth-phone-input>
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
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>import '@methane-ui/ui/phone-input';
import '@methane-ui/react';
export function Example() {
return <mth-phone-input placeholder="(555) 123-4567" autocomplete="tel-national"></mth-phone-input>;
}<script setup lang="ts">
import '@methane-ui/ui/phone-input';
</script>
<template>
<mth-phone-input placeholder="(555) 123-4567" autocomplete="tel-national"></mth-phone-input>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/ui/phone-input';
import { MthPhoneInputDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthPhoneInputDirective],
template: `<mth-phone-input placeholder="(555) 123-4567" autocomplete="tel-national"></mth-phone-input>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/ui/phone-input';
import MthPhoneInput from '@methane-ui/svelte/MthPhoneInput.svelte';
</script>
<MthPhoneInput placeholder="(555) 123-4567" autocomplete="tel-national"></MthPhoneInput>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
value | value | string | "" | Formatted national phone string. |
name | name | string | "" | Form submission field name. |
label | label | string | "" | Accessible label rendered inside shadow root. |
hint | hint | string | "" | Helper text displayed below control. |
error | error | string | "" | Explicit custom error message. |
placeholder | placeholder | string | "(555) 123-4567" | Placeholder displayed when empty. |
autocomplete | autocomplete | string | "tel-national" | HTML autocomplete token (defaults to tel-national). |
country | country | string | "US" | ISO 3166-1 alpha-2 country code (e.g. "US", "GB", "DE"). |
dialCode | dial-code | string | "+1" | International calling prefix (e.g. "+1", "+44"). |
mask | mask | string | "(000) 000-0000" | Mask pattern using 0/9 digit tokens or custom # digits. |
disabled | disabled | boolean | false | Disables interaction. |
required | required | boolean | false | Marks control required. |
readonly | readonly | boolean | false | Prevents edits while allowing focus and submission. |
Events
| Event | Detail Type | Description |
|---|---|---|
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
| Key | Direction | When | Expected Behavior |
|---|---|---|---|
| Enter | both | inside a form and not composing IME | requests submission of owning form |
Accessibility Checklist
| Category | Requirement | Verified By |
|---|---|---|
| aria | All aria-* IDREFs resolve within the same DOM root (ADR-003). | scanSameRootAria |
| focus | delegatesFocus: true with zero host internals.role (ADR-014). | lint-plugin & spec-compiler |
| contrast | Renders legible borders, focus outlines, and selection indicators under forced-colors: active. | Playwright forced-colors matrix |
| keyboard | Implements all 1 APG keyboard transitions across LTR/RTL. | mth-phone-input.spec.test.ts |
| states | Exposes ElementInternals CustomStateSet flags: :state(dirty), :state(touched), :state(user-invalid), :state(disabled), :state(required), :state(readonly). | Conformance suite |
| i18n | Routes 4 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |