Skip to content
Ringobook v3.27.0

Tooltip

Tooltips are small descriptive messages that clarify an element’s function. Render a .ro-tooltip bubble in your markup (or create one in JavaScript on hover/focus).

<div class="ro-tooltip">Basic tooltip</div>
Preview
Basic tooltip

Add .ro-tooltip-arrow and a side class (.ro-side-top, .ro-side-bottom, .ro-side-left, .ro-side-right) to control arrow direction in static markup.

<div class="ro-tooltip ro-side-top">
<span>top tooltip</span>
<svg width="12" height="6" viewBox="0 0 12 6" preserveAspectRatio="none" class="ro-tooltip-arrow">
<path d="M0 0L6 6L12 0"></path>
</svg>
</div>
<div class="ro-tooltip ro-side-bottom">
<span>bottom tooltip</span>
<svg width="12" height="6" viewBox="0 0 12 6" preserveAspectRatio="none" class="ro-tooltip-arrow">
<path d="M0 0L6 6L12 0"></path>
</svg>
</div>
<div class="ro-tooltip ro-side-left">
<span>left tooltip</span>
<svg width="12" height="6" viewBox="0 0 12 6" preserveAspectRatio="none" class="ro-tooltip-arrow">
<path d="M0 0L6 6L12 0"></path>
</svg>
</div>
<div class="ro-tooltip ro-side-right">
<span>right tooltip</span>
<svg width="12" height="6" viewBox="0 0 12 6" preserveAspectRatio="none" class="ro-tooltip-arrow">
<path d="M0 0L6 6L12 0"></path>
</svg>
</div>
Preview
top tooltip
bottom tooltip
left tooltip
right tooltip

Add .ro-mode-adaptive on .ro-tooltip for adaptive glass colors — useful on mixed or photographic backgrounds. This swaps --ro-tooltip-glass-color, --ro-tooltip-glass-bg, and --ro-tooltip-glass-border-gradient.

<div class="ro-tooltip ro-mode-adaptive ro-side-top">
<span>top tooltip</span>
<svg width="12" height="6" viewBox="0 0 12 6" preserveAspectRatio="none" class="ro-tooltip-arrow">
<path d="M0 0L6 6L12 0"></path>
</svg>
</div>
<div class="ro-tooltip ro-mode-adaptive ro-side-bottom">
<span>bottom tooltip</span>
<svg width="12" height="6" viewBox="0 0 12 6" preserveAspectRatio="none" class="ro-tooltip-arrow">
<path d="M0 0L6 6L12 0"></path>
</svg>
</div>
<div class="ro-tooltip ro-mode-adaptive ro-side-left">
<span>left tooltip</span>
<svg width="12" height="6" viewBox="0 0 12 6" preserveAspectRatio="none" class="ro-tooltip-arrow">
<path d="M0 0L6 6L12 0"></path>
</svg>
</div>
<div class="ro-tooltip ro-mode-adaptive ro-side-right">
<span>right tooltip</span>
<svg width="12" height="6" viewBox="0 0 12 6" preserveAspectRatio="none" class="ro-tooltip-arrow">
<path d="M0 0L6 6L12 0"></path>
</svg>
</div>
Preview
top tooltip
bottom tooltip
left tooltip
right tooltip

Tooltips have no open/close class in CSS — create and destroy (or show/hide) a .ro-tooltip element in response to mouseenter / focus on the trigger:

ConcernWhat to toggle
VisibilityAppend/remove the .ro-tooltip node, or toggle display / opacity
Arrow sideSet .ro-side-top, .ro-side-bottom, .ro-side-left, or .ro-side-right on the bubble
Adaptive colorsAdd .ro-mode-adaptive on the bubble
PositionSet position: fixed + left / top from the trigger’s getBoundingClientRect(), or use Floating UI
const trigger = document.querySelector('.my-trigger');
let tooltip = null;
function showTooltip() {
tooltip = document.createElement('div');
tooltip.className = 'ro-tooltip ro-side-top'; // arrow side class
tooltip.innerHTML = `
Help text
<svg width="12" height="6" viewBox="0 0 12 6" class="ro-tooltip-arrow">
<path d="M0 0L6 6L12 0"></path>
</svg>
`;
document.body.appendChild(tooltip);
const rect = trigger.getBoundingClientRect();
// Position above the trigger (adjust per ro-side-* class)
tooltip.style.position = 'fixed';
tooltip.style.left = `${rect.left + rect.width / 2}px`;
tooltip.style.top = `${rect.top - 8}px`;
tooltip.style.transform = 'translate(-50%, -100%)';
}
function hideTooltip() {
tooltip?.remove();
tooltip = null;
}
trigger.addEventListener('mouseenter', showTooltip);
trigger.addEventListener('mouseleave', hideTooltip);
trigger.addEventListener('focus', showTooltip);
trigger.addEventListener('blur', hideTooltip);
ClassDescription
.ro-tooltipTooltip bubble (glassmorphism surface).
.ro-tooltip-arrowArrow element pointing at the trigger.
.ro-side-top, .ro-side-bottom, .ro-side-left, .ro-side-rightArrow placement in static markup.
.ro-mode-adaptiveAdaptive glass colors on .ro-tooltip.
VariableDescription
--ro-tooltip-colorText color.
--ro-tooltip-p-inlineHorizontal padding.
--ro-tooltip-p-blockVertical padding.
--ro-tooltip-radiusBorder radius.
--ro-tooltip-border-widthGlass border width.
--ro-tooltip-glass-bgGlass background (set by theme mixin).
--ro-tooltip-glass-colorAdaptive text color (with .ro-mode-adaptive).

Changelog

Recent updates in @ringover/styles. See the full package changelog .

@ringover/styles@3.13.0
  • Reworked tooltip layout, arrow positioning, and playground parity.