Skip to content
FrameworkStyle

Tooltip

A tooltip component for displaying contextual labels on hover and focus

Import

import { Tooltip } from '@videojs/react';

Anatomy

<Tooltip.Provider>
  <Tooltip.Root>
    <Tooltip.Trigger>Hover me</Tooltip.Trigger>
    <Tooltip.Popup>
      <Tooltip.Arrow />
      <Tooltip.Label>Label text</Tooltip.Label>
      <Tooltip.Shortcut>K</Tooltip.Shortcut>
    </Tooltip.Popup>
  </Tooltip.Root>
</Tooltip.Provider>

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 component is composed from six parts: Root manages state and context, Trigger renders a button that activates the tooltip, Popup contains the label content, Label renders the tooltip body, Shortcut renders an optional keyboard hint, and Arrow renders a decorative pointer. Wrap multiple tooltips in a Tooltip.Provider to coordinate open/close timing across a group — once a tooltip becomes visible, adjacent tooltips open instantly within the timeout window, skipping the normal delay.

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:

React renders standard DOM elements. Add a className to style them:

.tooltip-popup {
  --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:

.tooltip-popup[data-open] {
  display: block;
}
.tooltip-popup[data-starting-style] {
  opacity: 0;
}
.tooltip-popup[data-ending-style] {
  opacity: 0;
}
.tooltip-popup[data-side="top"] {
  transform-origin: bottom center;
}
.tooltip-popup[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

import { Tooltip } from '@videojs/react';

export default function BasicUsage() {
  return (
    <div className="demo">
      <Tooltip.Root>
        <Tooltip.Trigger className="trigger">Hover me</Tooltip.Trigger>
        <Tooltip.Popup className="media-tooltip">
          <Tooltip.Arrow className="arrow" />
          <Tooltip.Label>Tooltip content</Tooltip.Label>
        </Tooltip.Popup>
      </Tooltip.Root>
    </div>
  );
}

Grouping

Wrap multiple tooltips in a Tooltip.Provider to share a delay group. Once a tooltip becomes visible, adjacent tooltips open instantly within the timeout window, skipping the normal delay.

import { Tooltip } from '@videojs/react';

export default function Grouping() {
  return (
    <div className="demo">
      <Tooltip.Provider>
        <Tooltip.Root>
          <Tooltip.Trigger className="trigger">Play</Tooltip.Trigger>
          <Tooltip.Popup className="media-tooltip">
            <Tooltip.Arrow className="arrow" />
            <Tooltip.Label>Play video</Tooltip.Label>
          </Tooltip.Popup>
        </Tooltip.Root>
        <Tooltip.Root>
          <Tooltip.Trigger className="trigger">Mute</Tooltip.Trigger>
          <Tooltip.Popup className="media-tooltip">
            <Tooltip.Arrow className="arrow" />
            <Tooltip.Label>Mute audio</Tooltip.Label>
          </Tooltip.Popup>
        </Tooltip.Root>
        <Tooltip.Root>
          <Tooltip.Trigger className="trigger">Fullscreen</Tooltip.Trigger>
          <Tooltip.Popup className="media-tooltip">
            <Tooltip.Arrow className="arrow" />
            <Tooltip.Label>Enter fullscreen</Tooltip.Label>
          </Tooltip.Popup>
        </Tooltip.Root>
      </Tooltip.Provider>
    </div>
  );
}

API Reference

Provider

Root

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 accessible via the render, className, and style props.

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

Trigger

Element that triggers the tooltip on hover and focus. Renders a <button> element.

Props

PropTypeDefaultDetails
classNamestring | ((state: TooltipState) => string | undefined)
renderReactElement | ((props: HTMLProps, state: TooltipState) => ReactElement | null)
styleCSSProperties | ((state: TooltipState) => CSSProperties | undefined)

Data attributes

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

Container for the tooltip content. Positioned relative to the trigger using CSS anchor positioning with a JavaScript fallback.

PropTypeDefaultDetails
classNamestring | ((state: TooltipState) => string | undefined)
renderReactElement | ((props: HTMLProps, state: TooltipState) => ReactElement | null)
styleCSSProperties | ((state: TooltipState) => CSSProperties | undefined)
AttributeTypeDetails
data-open
data-side'top' | 'bottom' | 'left' | 'right'
data-align'start' | 'center' | 'end'

Label

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

Props

PropTypeDefaultDetails
classNamestring | ((state: TooltipState) => string | undefined)
renderReactElement | ((props: HTMLProps, state: TooltipState) => ReactElement | null)
styleCSSProperties | ((state: TooltipState) => CSSProperties | undefined)

Data attributes

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

Shortcut

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

Props

PropTypeDefaultDetails
classNamestring | ((state: TooltipState) => string | undefined)
renderReactElement | ((props: HTMLProps, state: TooltipState) => ReactElement | null)
styleCSSProperties | ((state: TooltipState) => CSSProperties | undefined)

Data attributes

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

Arrow

Decorative arrow pointing from the tooltip toward the trigger. Hidden from assistive technology.

Props

PropTypeDefaultDetails
classNamestring | ((state: TooltipState) => string | undefined)
renderReactElement | ((props: HTMLProps, state: TooltipState) => ReactElement | null)
styleCSSProperties | ((state: TooltipState) => CSSProperties | undefined)