← All Components
<mth-mfa-challenge>
Multi-factor authentication challenge supporting 6-digit TOTP entry with multi-cell paste and backup recovery code entry.
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-mfa-challenge>, or toggle Theme, Direction (LTR/RTL), or props above.
Multi-Framework Playground & Snippets
<script type="module" src="@methane-ui/auth/mfa-challenge"></script>
<mth-mfa-challenge mode="totp" length="6"></mth-mfa-challenge>import '@methane-ui/auth/mfa-challenge';
import '@methane-ui/react';
export function Example() {
return <mth-mfa-challenge mode="totp" length="6"></mth-mfa-challenge>;
}<script setup lang="ts">
import '@methane-ui/auth/mfa-challenge';
</script>
<template>
<mth-mfa-challenge mode="totp" length="6"></mth-mfa-challenge>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/auth/mfa-challenge';
import { MthMfaChallengeDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthMfaChallengeDirective],
template: `<mth-mfa-challenge mode="totp" length="6"></mth-mfa-challenge>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/auth/mfa-challenge';
import MthMfaChallenge from '@methane-ui/svelte/MthMfaChallenge.svelte';
</script>
<MthMfaChallenge mode="totp" length="6"></MthMfaChallenge>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
mode | mode | 'totp' | 'backup' | "totp" | Active challenge verification mode (totp | backup). |
length | length | number | 6 | Number of TOTP digit cells. |
value | value | string | "" | Current entered verification or backup code. |
name | name | string | "" | Form field name submitted via ElementInternals. |
error | error | string | "" | External verification error message. |
loading | loading | boolean | false | Disables controls and shows verification submission progress. |
disabled | disabled | boolean | false | Disables code entry and action buttons. |
required | required | boolean | true | Whether a complete verification code is required for form validity. |
allowResend | allow-resend | boolean | false | Whether to display a resend code button. |
Events
| Event | Detail Type | Description |
|---|---|---|
mth-input | { value: string; mode: string } | Emitted on code input. |
mth-change | { value: string; mode: string } | Emitted on code commit. |
mth-complete | { value: string; mode: string } | Emitted when all TOTP digits are entered. |
mth-submit | { value: string; mode: string } | Emitted when verification is submitted. |
mth-resend | void | Emitted when the user requests a new code. |
mth-mode-change | { mode: string } | Emitted when toggling between totp and backup modes. |
APG Keyboard Matrix
| Key | Direction | When | Expected Behavior |
|---|---|---|---|
| ArrowRight | ltr | TOTP cell focused | Moves focus to next digit cell |
| ArrowLeft | rtl | TOTP cell focused | Moves focus to next digit cell in RTL |
| Backspace | both | Empty TOTP cell focused | Clears previous digit and focuses it |
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 3 APG keyboard transitions across LTR/RTL. | mth-mfa-challenge.spec.test.ts |
| states | Exposes ElementInternals CustomStateSet flags: :state(disabled), :state(invalid), :state(loading). | Conformance suite |
| i18n | Routes 12 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |