Getting startedComponentsDesign tokensThemingTheme synthesizerFrameworksAccessibilityUtilitiesServer renderingBrowser supportContributingChangelogApp ShellAspect GridAuth ShellCenterContainerDashboard GridFloat BarInsetMasonryPage HeaderPage LayoutResizableResponsive SwitcherSectionSettings LayoutSplit PaneStatus BarStickyToolbarAnchor NavBottom NavBreadcrumbBreadcrumb MenuCommand BarDrawerFooterLinkMenubarNavigation MenuPage IndicatorPaginationRailScroll IndicatorScroll SpyScroll To TopSidebarSkip LinkStepper NavTabsTop BarTree ViewAccordionAspect RatioAvatarAvatar GroupCardCarouselCollapsibleColor SwatchCTA BannerDividerEmpty StateFeature CardIconImageImage CompareImage HotspotsInfinite ScrollLightboxMarqueeQR CodeScroll AreaSkeletonSpinnerStackVideoVirtual ListActivity HeatmapAnimated NumberBadgeBar ListChartClockComparisonCountdown TimerData GridDescription ListDiffGaugeJSON TreeKanbanLevel MeterListMeterSparklineStatStepperTagTimelineUptimeValue CardWaveformBlockquoteCode BlockCode GroupGradient TextHighlightKbdKeyboard MapMarkdownNumber FormatProseTerminalTextTime AgoTruncateTypewriterButtonButton GroupCalendarCheckboxChipColor PickerComboboxCopy ButtonDate PickerDate Range PickerField ListFieldsetFile UploadFormHotkeyIcon ButtonImage CropperInline EditInputInput GroupKnobLabelMasked InputMulti SelectNumber InputPassword InputPin InputRadio GroupRange SliderRatingSearchSegmented ControlSelectSignature PadSliderSortable ListSwitch GroupTag InputTextareaTheme ToggleTime PickerToggleTransfer ListTree SelectAlertAnnouncementBannerCommand PaletteConfirmConnection StatusContext MenuConversationDialogDropdown MenuHover CardLoading OverlayNotification PanelPopoverProgressSheetToastTooltip
ARC UIARC Radiant Components
v4.9DocsComponentsTokensSynthesizer
Getting startedFrameworksServer renderingDesign tokensThemingTheme synthesizerTypographyUtilitiesAll componentsAccessibilityBrowser supportChangelogContributingStatsApp ShellAspect GridAuth ShellCenterContainerDashboard GridFloat BarInsetMasonryPage HeaderPage LayoutResizableResponsive SwitcherSectionSettings LayoutSplit PaneStatus BarStickyToolbarAnchor NavBottom NavBreadcrumbBreadcrumb MenuCommand BarDrawerFooterLinkMenubarNavigation MenuPage IndicatorPaginationRailScroll IndicatorScroll SpyScroll To TopSidebarSkip LinkStepper NavTabsTop BarTree ViewAccordionAspect RatioAvatarAvatar GroupCardCarouselCollapsibleColor SwatchCTA BannerDividerEmpty StateFeature CardIconImageImage CompareImage HotspotsInfinite ScrollLightboxMarqueeQR CodeScroll AreaSkeletonSpinnerStackVideoVirtual ListActivity HeatmapAnimated NumberBadgeBar ListChartClockComparisonCountdown TimerData GridDescription ListDiffGaugeJSON TreeKanbanLevel MeterListMeterSparklineStatStepperTagTimelineUptimeValue CardWaveformBlockquoteCode BlockCode GroupGradient TextHighlightKbdKeyboard MapMarkdownNumber FormatProseTerminalTextTime AgoTruncateTypewriterButtonButton GroupCalendarCheckboxChipColor PickerComboboxCopy ButtonDate PickerDate Range PickerField ListFieldsetFile UploadFormHotkeyIcon ButtonImage CropperInline EditInputInput GroupKnobLabelMasked InputMulti SelectNumber InputPassword InputPin InputRadio GroupRange SliderRatingSearchSegmented ControlSelectSignature PadSliderSortable ListSwitch GroupTag InputTextareaTheme ToggleTime PickerToggleTransfer ListTree SelectAlertAnnouncementBannerCommand PaletteConfirmConnection StatusContext MenuConversationDialogDropdown MenuHover CardLoading OverlayNotification PanelPopoverProgressSheetToastTooltip

Waveform

Draws an audio clip's shape from peak values you supply, and doubles as a seek control.

ComponentsWaveform
datahybrid
<arc-waveform>

Overview

Waveform draws an audio clip's shape from an array of peak amplitudes (one number per bar, 0 to 1) and marks playback progress on it. The played region is in the accent color with a soft glow, the unplayed region is muted, and a thin glowing playhead sits at the current position. Set `interactive` and the same element becomes a scrubber, with pointer dragging, keyboard seeking and slider semantics for assistive technology. `variant="bars"` draws one bar per peak, centered on the middle line, and `mirror` draws a filled min/max envelope. The component doesn't load, decode or play audio. You compute the peaks however you like (from a decoded buffer, a server-side analysis pass or a cached sidecar file) and pass them as the `peaks` property. The SVG depends only on its props, so it renders on the server. `position` is a fraction of the total (0 to 1), not seconds. If your player thinks in seconds, divide by the duration on the way in and multiply on the way out. With `duration` set, the `time` field on both event details does the multiplying for you, a monospace time readout appears below the track, and screen readers hear elapsed and total time instead of a percentage. While the reader scrubs, `arc-input` fires on every pointer move with the live position, and `arc-change` fires once on release with the final one, as with ARC UI's other inputs. Seek your audio source on `arc-change`, and use `arc-input` for live feedback such as a time display or audible scrubbing.

Guidelines

Do

  • Compute peaks once per clip and cache them. A few dozen to a few hundred values is plenty, and each is clamped to 0 to 1
  • Set `duration` whenever you know it
  • Give every waveform a `label`. It names the slider, or describes the image when the waveform isn't interactive
  • Use `bars` for scrubbers and player UI, and `mirror` for dense timeline lanes where separate bars would shimmer
  • Set the height with `--waveform-height` when the default doesn't suit its row

Don't

  • Don't use it for general trend data. Use Sparkline. The mirrored geometry distorts ordinary series
  • Don't use it as a level indicator or progress bar. Meter shows one current value against a range
  • Don't feed it raw sample data. Downsample to peaks first. In `bars`, every peak is its own SVG element
  • Don't seek your audio source on `arc-input`. It fires on every pointer move

Features

  • Keyboard seeking with the arrow keys, PageUp and PageDown, and Home and End
  • `steps` divides the track into discrete frames, and the arrow keys move one step
  • `value-text` replaces the screen reader wording with your own
  • A slider when interactive, and a labeled image otherwise
  • Scales with its SVG viewBox, so it fits any width without measuring
  • Empty or missing peaks render an empty track, not an error

Preview

Bars, interactive. Drag or use the arrow keys to seek
Mirror envelope, static

Usage

Waveform is in the media group, so the default @arclux/arc-ui entry point doesn't include it. Import it from@arclux/arc-ui/media or from its own subpath,@arclux/arc-ui/waveform.

Its events and state need JavaScript, so use the Web Component or a framework wrapper for those.

<script type="module" src="@arclux/arc-ui"></script>

<!-- Interactive scrubber with time readouts -->
<arc-waveform id="scrubber" interactive duration="212" label="Track position"></arc-waveform>

<!-- Static clip preview, mirror envelope -->
<arc-waveform id="clip" variant="mirror" position="0.6" label="Vocal take"></arc-waveform>

<script type="module">
  const scrubber = document.getElementById('scrubber');

  // Peaks are a property, not an attribute — you compute them (0..1 per bar).
  scrubber.peaks = await fetchPeaks('track-7');

  scrubber.addEventListener('arc-input', (e) => {
    // Live position while dragging: e.detail.value is 0..1,
    // e.detail.time is seconds because duration is set.
    timeDisplay.textContent = format(e.detail.time);
  });
  scrubber.addEventListener('arc-change', (e) => {
    audio.currentTime = e.detail.time; // seek once, on release
  });

  // Follow playback
  audio.addEventListener('timeupdate', () => {
    scrubber.position = audio.currentTime / audio.duration;
  });
</script>

API

labelstring''
Accessible name for the waveform. Announced as the slider label when interactive, or as the image description otherwise.
peaksArray[]
Peak amplitudes as a number array, each value 0 to 1. Set it from script, a framework binding, or a JSON attribute. Values outside the range are clamped. An empty or missing array renders an empty track.
positionnumber0
Current playhead position as a fraction of the total, 0 to 1. Not seconds: multiply by duration yourself if you track seconds. Updated by the component during scrubbing and reflected as an attribute.
durationnumber0
Total duration in seconds. Optional; when set, time readouts render below the waveform and the slider announces times instead of percentages.
interactivebooleanfalse
Enables scrubbing. The waveform becomes a focusable slider: click or drag to seek, arrow keys to nudge, Home/End to jump. Without it the waveform is a static image.
variant'bars' | 'mirror''bars'
Rendering style. bars draws discrete bar pairs mirrored around the center line; mirror draws a filled min/max envelope.
stepsnumber0
Divides the track into this many equal steps, for a timeline of discrete frames rather than continuous audio. The playhead snaps to a step from pointer and keyboard alike, arrow keys move one step, Page Up/Down a tenth of the track (at least one step), and the slider reports the step number rather than a percentage. Unset, the track is continuous.
value-textstring
What the slider announces for the current position, replacing the built-in percentage or time. Set it from your arc-input handler, which runs before the position renders, so the text and the value always arrive together (e.g. "85 of 200 ms").

Events

arc-inputdetail:{ value: number, time: number | null }
Fired continuously while scrubbing (every pointer move and each keyboard nudge). value is the position fraction 0-1; time is seconds when duration is set, otherwise null. Use for live preview: updating a time display, or audibly scrubbing.
arc-changedetail:{ value: number, time: number | null }
Fired once when the seek commits: on pointer release, or with each keyboard nudge. Use for the actual seek on your audio source.

See also