← All Components
<mth-waveform>
Accessible audio waveform visualizer and keyboard-scrubbable seekbar.
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-waveform>, or toggle Theme, Direction (LTR/RTL), or props above.
Multi-Framework Playground & Snippets
<script type="module" src="@methane-ui/media/waveform"></script>
<mth-waveform current-time="0" duration="0"></mth-waveform>import '@methane-ui/media/waveform';
import '@methane-ui/react';
export function Example() {
return <mth-waveform current-time="0" duration="0"></mth-waveform>;
}<script setup lang="ts">
import '@methane-ui/media/waveform';
</script>
<template>
<mth-waveform current-time="0" duration="0"></mth-waveform>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/media/waveform';
import { MthWaveformDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthWaveformDirective],
template: `<mth-waveform current-time="0" duration="0"></mth-waveform>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/media/waveform';
import MthWaveform from '@methane-ui/svelte/MthWaveform.svelte';
</script>
<MthWaveform current-time="0" duration="0"></MthWaveform>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
src | src | string | "" | Media audio source URL validated against the safe URL allowlist. |
playing | playing | boolean | false | Whether audio playback is currently active. |
disabled | disabled | boolean | false | Disables interactive scrubbing and playback controls. |
currentTime | current-time | number | 0 | Current playback time in seconds. |
duration | duration | number | 0 | Total media duration in seconds. |
barCount | bar-count | number | 48 | Number of normalized amplitude bars rendered in the waveform. |
label | label | string | "" | Accessible region label. |
peaks | — | readonly number[] | — | Precomputed amplitude peak array (0..1). |
Events
| Event | Detail Type | Description |
|---|---|---|
mth-play | { currentTime: number } | Fired when playback starts. |
mth-pause | { currentTime: number } | Fired when playback pauses. |
mth-seek | { currentTime: number; progress: number } | Fired when the playback position changes. |
mth-error | { reason: string } | Fired when an invalid or unsafe source URL is rejected. |
APG Keyboard Matrix
| Key | Direction | When | Expected Behavior |
|---|---|---|---|
| ArrowRight | ltr | Focus is on the waveform scrubber | Seeks forward along the audio timeline |
| ArrowLeft | ltr | Focus is on the waveform scrubber | Seeks backward along the audio timeline |
| Home | both | Focus is on the waveform scrubber | Seeks to the start of the waveform |
| End | both | Focus is on the waveform scrubber | Seeks to the end of the waveform |
both | Focus is on the waveform scrubber | Toggles audio playback |
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 5 APG keyboard transitions across LTR/RTL. | mth-waveform.spec.test.ts |
| states | Exposes ElementInternals CustomStateSet flags: :state(playing), :state(disabled), :state(reduced-motion). | Conformance suite |
| i18n | Routes 7 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |