← All Components
<mth-masked-input>
Form-associated pattern-masked input powered by MaskAndFormatEngine with cursor-preserving editing and completeness validation.
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-masked-input>, or toggle Theme, Direction (LTR/RTL), or props above.
Multi-Framework Playground & Snippets
<script type="module" src="@methane-ui/ui/masked-input"></script>
<mth-masked-input mask="0000-0000"></mth-masked-input>import '@methane-ui/ui/masked-input';
import '@methane-ui/react';
export function Example() {
return <mth-masked-input mask="0000-0000"></mth-masked-input>;
}<script setup lang="ts">
import '@methane-ui/ui/masked-input';
</script>
<template>
<mth-masked-input mask="0000-0000"></mth-masked-input>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/ui/masked-input';
import { MthMaskedInputDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthMaskedInputDirective],
template: `<mth-masked-input mask="0000-0000"></mth-masked-input>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/ui/masked-input';
import MthMaskedInput from '@methane-ui/svelte/MthMaskedInput.svelte';
</script>
<MthMaskedInput mask="0000-0000"></MthMaskedInput>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
value | value | string | "" | Formatted (or unmasked if unmaskOnSubmit) input 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 | "" | Placeholder displayed when empty. |
autocomplete | autocomplete | string | "" | HTML autocomplete attribute forwarded to the control. |
mask | mask | string | "0000-0000" | Mask template (0/9/# digit, A letter, * alphanumeric). |
unmaskOnSubmit | unmask-on-submit | boolean | false | Submits raw unmasked value in FormData while displaying formatted value. |
disabled | disabled | boolean | false | Disables user interaction. |
required | required | boolean | false | Marks field required. |
readonly | readonly | boolean | false | Prevents edits while remaining focusable. |
Events
| Event | Detail Type | Description |
|---|---|---|
mth-input | { value: string; unmasked: string; complete: boolean } | Fired synchronously when masked input updates. |
mth-change | { value: string; unmasked: string; complete: boolean } | Fired when edited value commits. |
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-masked-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 3 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |