← All Components
<mth-stopwatch>
Interactive stopwatch with Start/Pause/Lap/Reset controls, tabular-numeral <time> display, clean interval teardown on disconnect, and discrete polite live-region announcements.
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-stopwatch>, or toggle Theme, Direction (LTR/RTL), or props above.
Multi-Framework Playground & Snippets
<script type="module" src="@methane-ui/ui/stopwatch"></script>
<mth-stopwatch show-milliseconds></mth-stopwatch>import '@methane-ui/ui/stopwatch';
import '@methane-ui/react';
export function Example() {
return <mth-stopwatch show-milliseconds></mth-stopwatch>;
}<script setup lang="ts">
import '@methane-ui/ui/stopwatch';
</script>
<template>
<mth-stopwatch show-milliseconds></mth-stopwatch>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/ui/stopwatch';
import { MthStopwatchDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthStopwatchDirective],
template: `<mth-stopwatch show-milliseconds></mth-stopwatch>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/ui/stopwatch';
import MthStopwatch from '@methane-ui/svelte/MthStopwatch.svelte';
</script>
<MthStopwatch show-milliseconds></MthStopwatch>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
running | running | boolean | false | Indicates or controls whether the stopwatch is currently timing. |
showMilliseconds | show-milliseconds | boolean | true | Displays centiseconds/milliseconds fraction when true. |
disabled | disabled | boolean | false | Disables all stopwatch controls. |
Events
| Event | Detail Type | Description |
|---|---|---|
mth-start | { elapsedMs: number } | Emitted when timing begins or resumes. |
mth-pause | { elapsedMs: number } | Emitted when timing pauses. |
mth-reset | { elapsedMs: number } | Emitted when elapsed time and laps are cleared. |
mth-lap | { index: number; lapMs: number; totalMs: number } | Emitted when a lap split is recorded. |
APG Keyboard Matrix
| Key | Direction | When | Expected Behavior |
|---|---|---|---|
| Enter | both | Start/Pause, Lap, or Reset button is focused | Activates the focused stopwatch control |
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-stopwatch.spec.test.ts |
| states | Exposes ElementInternals CustomStateSet flags: :state(running), :state(disabled). | Conformance suite |
| i18n | Routes 6 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |