Skip to content
FrameworkStyle

Tooltip

A tooltip component for displaying contextual labels on hover and focus

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.

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

The trigger receives aria-describedby pointing to the popup when open. The popup renders with role="tooltip" and popover="manual". Tooltips open on focus and close when focus leaves, ensuring keyboard-only users can access the label.

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

Props

PropTypeDefaultDetails
closeDelaynumber
delaynumber
timeoutnumber

Root

Props

PropTypeDefaultDetails
align'start' | 'center' | 'end''center'
closeDelaynumber0
defaultOpenbooleanfalse
delaynumber600
disabledbooleanfalse
disableHoverablePopupbooleantrue
openbooleanfalse
side'top' | 'bottom' | 'left' | 'right''top'

State

State is accessible via the render, className, and style props.

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

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.

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.

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.

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).

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.