Skip to content
FrameworkStyle

media-tooltip

A tooltip component for displaying contextual labels on hover and focus

Import

import '@videojs/html/ui/tooltip';

Anatomy

<media-tooltip-group>
  <button commandfor="my-tooltip">Hover me</button>
  <media-tooltip id="my-tooltip">
    <media-tooltip-label>Label text</media-tooltip-label>
    <media-tooltip-shortcut>K</media-tooltip-shortcut>
  </media-tooltip>
</media-tooltip-group>

Behavior

Displays a short label anchored to a trigger element. Opens after a configurable delay (default 600ms) on hover or immediately on focus. Closes when the pointer leaves or focus moves away, with an optional closeDelay.

The side and align props control the preferred placement relative to the trigger. When the preferred side overflows the positioning boundary, the tooltip uses the opposite side if it has more space. Positioning uses CSS Anchor Positioning where supported, with a JavaScript measurement fallback.

The <media-tooltip> element is the popup itself. Link it to a trigger using the commandfor attribute on any button, pointing to the tooltip’s id. The element discovers its trigger automatically and manages open/close state and positioning. Wrap tooltip trigger/popup pairs in <media-tooltip-group> to coordinate timing — the group’s delay, close-delay, and timeout attributes control shared timing for all contained tooltips.

Tooltips inside a Container also observe its popup group. By default, a tooltip does not open—or closes if already open—while a menu or popover attached to the same trigger is open. Set sticky when the tooltip should remain visible with that trigger’s popup. Tooltip.Provider and <media-tooltip-group> coordinate tooltip delay timing only; they do not replace the container’s popup group.

Styling

Use CSS custom properties for positioning offsets:

media-tooltip {
  --media-tooltip-side-offset: 8px;
  --media-tooltip-align-offset: 0px;
  --media-tooltip-boundary-offset: 8px;
}

Style based on open state, rendered side, and transition phases. data-side reflects the rendered side and can differ from the preferred side prop after collision handling:

media-tooltip[data-open] {
  display: block;
}
media-tooltip[data-starting-style] {
  opacity: 0;
}
media-tooltip[data-ending-style] {
  opacity: 0;
}
media-tooltip[data-side="top"] {
  transform-origin: bottom center;
}
media-tooltip[data-side="bottom"] {
  transform-origin: top center;
}

Accessibility

Tooltips are visual-only, supplementary labels. The popup renders with role="presentation" and is not referenced by the trigger with aria-describedby. Give the trigger its own accessible name instead of relying on tooltip content. Built-in media buttons already expose a state-aware aria-label, and their tooltips reuse that translated label. Tooltips still open on focus so keyboard users who can see the label receive the same visual hint.

Examples

Basic Usage

Tooltip content
<div class="demo">
  <button type="button" commandfor="tooltip-demo" class="trigger">Hover me</button>
  <media-tooltip id="tooltip-demo" class="media-tooltip"> Tooltip content </media-tooltip>
</div>

Grouping

Wrap tooltip trigger/popup pairs in <media-tooltip-group> to coordinate timing. The group’s delay, close-delay, and timeout attributes control shared timing for all contained tooltips.

Play video Mute audio Enter fullscreen
<media-tooltip-group class="demo">
  <button type="button" commandfor="tooltip-play" class="trigger">Play</button>
  <media-tooltip id="tooltip-play" class="media-tooltip">Play video</media-tooltip>

  <button type="button" commandfor="tooltip-mute" class="trigger">Mute</button>
  <media-tooltip id="tooltip-mute" class="media-tooltip">Mute audio</media-tooltip>

  <button type="button" commandfor="tooltip-fullscreen" class="trigger">Fullscreen</button>
  <media-tooltip id="tooltip-fullscreen" class="media-tooltip">Enter fullscreen</media-tooltip>
</media-tooltip-group>

API Reference

media-tooltip-group

media-tooltip

Props

PropTypeDefaultDetails
align'start' | 'center' | 'end''center'
boundary'viewport' | 'container' | string & o...
closeDelaynumber0
defaultOpenbooleanfalse
delaynumber600
disabledbooleanfalse
disableHoverablePopupbooleantrue
openbooleanfalse
side'top' | 'bottom' | 'left' | 'right''top'
stickybooleanfalse

State

State is reflected as data attributes for CSS styling.

PropertyTypeDetails
transitionStartingboolean
transitionEndingboolean
openboolean
status'idle' | 'starting' | 'ending'
side'top' | 'bottom' | 'left' | 'right'
align'start' | 'center' | 'end'

Data attributes

AttributeTypeDetails
data-open
data-side'top' | 'bottom' | 'left' | 'right'
data-align'start' | 'center' | 'end'

CSS custom properties

VariableDetails
--media-tooltip-side-offset
--media-tooltip-align-offset
--media-tooltip-boundary-offset
--media-tooltip-anchor-width
--media-tooltip-anchor-height
--media-tooltip-available-width
--media-tooltip-available-height

Events

EventDescription
open-changeFired when the tooltip's open state changes.

media-tooltip-label

Tooltip body label; defaults to context content.label from the linked trigger.

Data attributes

AttributeTypeDetails
data-open
data-side'top' | 'bottom' | 'left' | 'right'
data-align'start' | 'center' | 'end'

media-tooltip-shortcut

Keyboard shortcut hint; apply skin className (CSS: media-tooltip__kbd; Tailwind: popup.tooltipShortcut).

Data attributes

AttributeTypeDetails
data-open
data-side'top' | 'bottom' | 'left' | 'right'
data-align'start' | 'center' | 'end'