API Reference

Headless controls

The 13 unstyled control primitives - Vue and custom-element usage, styling, and CSS variables.

Unstyled primitives for building a custom HUD. Each is published as both a Vue component and an ml-video-* custom element from the same source. Vue components come from the main import; custom elements from /element or the smaller /element/controls.

import {
  PlayButton,
  MuteButton,
  FullscreenButton,
  LoopButton,
  PipButton,
  CaptionsButton,
  QualityButton,
  PlaybackRateButton,
  Buffering,
  Scrubber,
  VolumeSlider,
  TimeDisplay,
  Transcript,
} from '@munsonlabs/video-player'
ComponentCustom elementDescription
PlayButton<ml-video-play-button>Toggles play/pause; becomes Replay after ended and Retry (calling retry()) after an error
MuteButton<ml-video-mute-button>Toggles mute
FullscreenButton<ml-video-fullscreen-button>Toggles fullscreen
LoopButton<ml-video-loop-button>Toggles loop
PipButton<ml-video-pip-button>Picture-in-Picture - only renders when supportsPip
CaptionsButton<ml-video-captions-button>Cycles Off → track 1 → … → Off; only when supportsCaptions
QualityButton<ml-video-quality-button>Cycles Auto → highest → … → Auto; only when supportsQuality
PlaybackRateButton<ml-video-playback-rate-button>Cycles 0.5, 0.75, 1, 1.25, 1.5, 2; only renders when supportsPlaybackRate
Buffering<ml-video-buffering>Renders its content only while isBuffering
Scrubber<ml-video-scrubber>Drag-to-seek range input - pauses on drag, previews time, resumes on release
VolumeSlider<ml-video-volume-slider>Drag-to-set-volume range input with a percentage readout
TimeDisplay<ml-video-time-display>Elapsed / duration, or a "Live" badge when isLive. Wraps each half in .ml-video-time-display__time / __total for independent styling. Its slot gives { isLive, currentTime, duration, formatTime }
Transcript<ml-video-transcript>Clickable transcript from cues, with an optional spoken readout of the active cue - see transcripts

Pointing a control at a player

Via a player ref, or <label for>-style via an element id:

<script setup>
import { ref } from 'vue'
import { VideoPlayer, PlayButton, MuteButton, Scrubber } from '@munsonlabs/video-player'
const player = ref(null)
</script>

<template>
  <VideoPlayer ref="player" src="..." :controls="false" />
  <PlayButton :player="player" />
  <MuteButton :player="player" />
  <Scrubber :player="player" />
</template>

Or skip the wiring entirely by nesting the control inside VideoPlayer, VideoCard or VideoStage, which resolves it through context. A card or stage passes it to the player it renders, so the HUD arrives with the player rather than over a lazy placeholder. This is Vue only: the custom elements consume their own children rather than passing them to a slot, so <ml-video-*> uses for instead.

<VideoPlayer src="..." :controls="false">
  <PlayButton />
</VideoPlayer>

for also works against a Vue player, but the id has to sit on an element that actually carries the handle - put it on your own wrapper and call exposePlayerOnElement. An id on <VideoPlayer> itself lands on a plain wrapper div, which has no handle to find. On the custom-element form below, for needs none of that: Vue puts the handle on the element itself.

Loading player…

No built-in HUD - the bar and transcript below are the headless primitives, wired to the player by ref. Click a transcript line to seek.

Both are optional; player wins if both are given. for resolves through document.getElementById - this package never uses shadow DOM, so an id lookup is always correct. for is the zero-JS path; the property form (el.player = ...) is only needed when the two can't share a stable id, since an object reference isn't expressible as an attribute.

A bare attribute casts to true (play-in-view), but ="false" arrives as the truthy string"false" - so controls="false" on <ml-video-player> leaves the built-in HUD on. Set boolean props to false through the property instead: playerEl.controls = false.

Scoped slots (Vue only)

Each button exposes its state for fully custom markup - PlayButton gives { isPlaying, hasEnded, isError }, MuteButton { isMuted }, and so on:

<PlayButton :player="player" v-slot="{ isPlaying }">
  {{ isPlaying ? 'Pause' : 'Play' }}
</PlayButton>

A scoped slot is a render-function callback with no HTML equivalent, so custom elements can't have them. Static children still work as a plain default slot (<ml-video-buffering><div class="spinner"></div></ml-video-buffering>); for state-reactive markup, toggle your own elements on state-change.

Styling

Every control button's CSS uses :where() (zero specificity), so one class of yours always wins regardless of source order. The two range inputs are the exception: Scrubber and VolumeSlider each keep a real-specificity wrapper class, and Scrubber's focus ring is !important. In Vue, a class falls through to the control's root element:

<PlayButton :player="player" class="my-play-btn" />

As a raw custom element it doesn't. The custom element is a persistent DOM node that Vue renders into; a class on the outer tag never reaches the <button> inside. Use a descendant selector:

ml-video-play-button button {
  color: red;
}
/* or the built-in class: */
ml-video-play-button .ml-video-play-button {
  color: red;
}

CSS entry points

ImportPairs withCovers
/style/element, and plain Vue usageCore player + all 13 controls
/style/core/element/coreJust the player components
/style/controls/element/controlsJust the 13 controls

Only /element auto-injects its CSS. Building a fully custom HUD? /style/controls alone is enough - no need to ship the core player's CSS you never render.

Themeable CSS variables

Set these on any ancestor of the player:

VariableDefaultControls
--ml-video-max-width800pxWidth cap on the player, its lazy placeholder and the stage - set none to fill the container
--ml-video-controls-widthmin(450px, calc(100% - 32px))Expanded controls popup width
--ml-video-popup-aligncenterPopup horizontal alignment
--ml-video-btn-bgfrosted glassHUD button background
--ml-video-btn-color#fffHUD button icon/text colour
--ml-video-stage-tuck32pxSliver left visible when HideMarker tucks a pinned box away
--ml-video-radius12pxCorner-pinned box border radius
--ml-video-accent#3b82f6Accent for the HUD sliders, active toggles, more-menu rows and the transcript's active cue
.my-video-wrapper {
  --ml-video-btn-bg: #e11d48;
  --ml-video-btn-color: #fff;
}

Icons use fill="currentColor", so --ml-video-btn-color recolours them too. Popup show/hide and fullscreen docking are covered on the behaviour page.

munsonlabs · MIT licensed · © 2026