Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…

Read the release notes

audio-player

Platform audio player that wraps native <audio> with custom controls in shadow DOM. Progressive enhancement — native audio works without JS.

Overview

A platform-native audio player that wraps <audio> in light DOM and renders custom controls in shadow DOM. The native player is always the fallback — if JS is unavailable or the component fails, <audio controls> works normally.

Pair with <audio-visualizer> for canvas-based frequency or waveform visualization.

Single Track

Playlist Mode

Include a <details> with <ol class="track-list"> inside the component. Clicking a track updates the audio source and plays it. When a track ends it is marked data-audio-played, keeps data-audio-active until the next track starts, and playback advances in list order, stopping after the last track (or wrapping with loop).

Shuffle and Loop

With shuffle, the next track is picked at random from the tracks not yet played in the current cycle, so a track never plays twice in a row. Without loop playback stops once every track has played; with loop a new shuffled cycle starts. Clicking a track counts it as played for the cycle, and toggling shuffle starts a fresh cycle.

Attributes

AttributeTypeDescription
autoplayBooleanStart playing on load (subject to browser autoplay policy)
loopBooleanLoop the track (single-track mode sets the native audio.loop) or wrap the playlist back to the first track; with shuffle, start a new shuffled cycle
shuffleBooleanAdvance to a random unplayed track (once per cycle, never twice in a row)

Reflected state

Set by the component — read them, style with them, but don't author them.

AttributeValuesDescription
stateplaying | paused | endedCurrent playback state
mutedBooleanMirrors the inner audio.muted
data-stateerrorThe audio (or every <source>) failed to load. The player shows a visible message, announced politely to screen readers. Cleared when a source loads

The native controls attribute belongs on the inner <audio>: it is the no-JS fallback. The component removes it while upgraded and restores it if the player is removed from the page.

Properties

PropertyTypeDescription
srcStringGet or set the audio source. Setting it loads the new source, refreshes the title, moves data-audio-active to a matching track link (if any) and fires audio-player:src-changed
currentTimeNumberPlayback position in seconds

CSS Custom Properties

PropertyDefaultDescription
--audio-player-accentvar(--color-primary)Play button, slider thumbs, and progress fill color
--audio-player-bgvar(--color-surface)Player background and slider thumb border color
--audio-player-radiusvar(--radius-m)Player border radius
--audio-player-textvar(--color-text)Track title and controls text color
--audio-player-bordervar(--color-border)Player border and slider track color
--audio-player-shadownonePlayer box shadow (opt-in)
--audio-player-paddingvar(--size-xs) var(--size-s)Controls area padding

Dark Mode

The player adapts automatically to light and dark mode via design tokens. All colors resolve through CSS custom properties that respond to theme changes. Set data-mode="dark" on the player or any ancestor (such as the <section> it sits in), or let the system preference apply.

Elevated Card Style

Opt in to a shadow with --audio-player-shadow for a raised card look. Set the properties in your stylesheet on a class:

Shadow Parts

PartDescription
playerOuter player container
controlsControls row
play-buttonPlay/pause button
timelineSeek range input
volumeVolume range input
track-infoTrack title and time display
errorLoad-error message (hidden unless data-state="error")

Events

EventDetail
audio-player:play{ currentTime, src }
audio-player:pause{ currentTime }
audio-player:ended{ src }
audio-player:track-change{ src, title }
audio-player:src-changed{ src, source: 'property' }

Keyboard Shortcuts

KeyAction
SpacePlay / Pause
Left ArrowSeek back 10 seconds
Right ArrowSeek forward 10 seconds
MToggle mute

Shortcuts apply when focus is anywhere inside the player. The player itself is not a tab stop: it is exposed as a group named “Audio player” with aria-keyshortcuts, and Tab moves straight to its controls. A key that the focused control uses itself is left to that control: Space on the play or mute button or the playlist <summary> activates only that control, and the arrow keys on the seek or volume slider adjust only that slider. Every other shortcut still works from those controls, so M mutes from the seek slider and the arrow keys seek from the play button. Keys typed in a text field, <select> or <textarea> placed inside the player are never treated as shortcuts.

Progressive Enhancement

The <audio> element lives in light DOM. Before JS loads, native controls render. After the component upgrades, native controls are hidden and custom chrome takes over. If the component is removed from the DOM, native controls are restored.

Track List Data Attributes

<li> elements in .track-list use data attributes for state:

AttributeSet byMeaning
data-audio-activeComponent + authorCurrently loaded/playing track
data-audio-playedComponentTrack has been played this session
data-audio-favoriteAuthorEditorially marked as a highlight

Not using the component? Put a native <audio controls> and the same track list in a container with the data-audio-playlist attribute. The playlist utility gives it the same click-to-play and advance-on-ended behavior (without shuffle or list looping). See the native audio page.

Accessibility

  • All controls have aria-label attributes
  • The host has role="group" and the label “Audio player” (author-supplied role, aria-label or aria-labelledby are kept)
  • The seek slider announces the position as text, e.g. “1:05 of 3:20” (aria-valuetext), updated during playback and seeking
  • The mute button keeps the stable label “Mute” and reports its state with aria-pressed
  • Load failures show a visible message in a role="status" region, so screen readers announce it politely
  • Keyboard navigable: every control is a native focusable element, the host adds no extra tab stop, and the shortcuts work from any control without overriding that control's own keys
  • Respects prefers-reduced-motion
  • Falls back to fully accessible native <audio> without JS

Companion: audio-visualizer

Pair with <audio-visualizer> for canvas-based frequency or waveform display. The visualizer is a separate component — it connects to any <audio> via the for attribute.

Related

  • <audio> — Native audio element (Layers 1-3)
  • <audio-visualizer> — Canvas visualization companion
  • controls — The browser's built-in media controls
  • preload — How much media to download before play
↑