Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…

Read the release notes

tool-tip

Progressive enhancement tooltips: native title fallback upgraded to styled popovers with arrows and positioning.

Overview

Tooltips use a title-first progressive enhancement approach. The title attribute provides a no-JS fallback (native browser tooltip). When JavaScript loads, the init script reads the title, removes it, and creates a styled popover with arrows and positioning.

Progressive Enhancement

State What the user sees
No JavaScript Native browser tooltip from title attribute
JavaScript loaded Styled popover with arrow, positioned via CSS Anchor or JS fallback

Simple Text Tooltip (Tier 1)

Add title and data-tooltip (no value) to any element. The init script creates the popover automatically.

Positions

Use data-tooltip-position to control where the tooltip appears relative to the trigger.

With Different Elements

Tooltips work on any focusable element: buttons, links, and elements with tabindex.

Attributes

Attribute On Description
title trigger Tooltip text. Read by the init script and removed to prevent a native double tooltip. When it was the trigger's only accessible name (icon-only button), it is copied to aria-label first.
data-tooltip trigger Marker for init script discovery. No value = create from title. With value = reference popover by ID.
data-tooltip-position trigger Position: top (default), bottom, left, or right.

Rich HTML Tooltip (Tier 2)

For tooltips with formatted content (keyboard shortcuts, icons, multiple lines), use data-tooltip="id" to reference an existing popover element. The title provides a plain-text no-JS fallback.

Card Variant (Tier 3)

For richer content previews like user profiles or link previews, use <tool-tip variant="card">. Cards use popover="manual" for interactive content and have longer show/hide delays.

Keyboard and reconnects

  • Focusing the trigger opens the card; Tab moves into it and the card stays open while focus is inside. Leaving the card closes it.
  • Escape closes the card and, when focus was inside it, returns focus to the trigger. A click outside closes it too.
  • The trigger gets aria-controls (the card) and aria-expanded, kept in step with the card.
  • Moving the <tool-tip> in the DOM is safe: on disconnect the [data-content] element is put back, and the card is rebuilt on reconnect.

Differences from Regular Tooltip

Feature Tooltip (Tier 1/2) Card variant
Content model title or data-tooltip="id" [data-trigger] + [data-content]
Appearance Dark, compact, with arrow Light card surface, border, shadow, no arrow
Show delay 200ms 300ms
Hide delay 100ms 200ms
Popover type hint (manual plus own Escape / outside dismiss where hint is unsupported) manual (supports interactive content)
ARIA role="tooltip", aria-describedby (appended to authored ids) aria-controls + aria-expanded on the trigger

tool-tip with Title Fallback

The <tool-tip> component also reads title from its trigger as a content source (lowest priority after <template data-tooltip> and content). This gives progressive enhancement to the web component path too.

Content priority in tool-tip:

  1. <template data-tooltip> (rich HTML)
  2. content attribute (plain text)
  3. title on trigger (PE baseline — read and removed)

Pure HTML Tooltips — interestfor (Tier 0)

For simple tooltips that don't need arrows, custom positioning, or rich content, you can skip the init script entirely. The interestfor attribute (native in Chrome 142+, polyfilled in other browsers) handles hover/focus timing and popover show/hide declaratively.

Custom Timing

The delays belong on the invoker (the element with interestfor), not on the popover: that is where native interest invokers and VB's polyfill read them. VB sets 200ms to show and 100ms to hide on every [interestfor]. Set the standard interest-delay-start / interest-delay-end properties for native support, and the --interest-delay-* custom properties the polyfill reads in other browsers:

When to Use Which

Use case Approach
Simple text hint on a button/link title + data-tooltip (Tier 1)
Rich content (kbd shortcuts, icons) data-tooltip="id" referencing a popover (Tier 2)
Interactive hover card (profiles, previews) <tool-tip variant="card"> (Tier 3)
Zero-JS inline definition interestfor + popover="hint" (Tier 0)

How It Works

Popover API

Tooltips use the native Popover API with popover="hint". This renders tooltips in the browser's top layer, avoiding z-index conflicts and overflow clipping issues.

CSS Anchor Positioning

In modern browsers (Chrome 125+, Safari 18+), tooltips use CSS Anchor Positioning for smooth, hardware-accelerated positioning. Older browsers fall back to JavaScript positioning automatically.

Browser Support

Browser Positioning Notes
Chrome 125+ CSS Anchor Full support
Safari 18+ CSS Anchor Full support
Firefox JS Fallback Anchor positioning not yet supported
Older browsers JS Fallback Requires Popover API support

Attributes (tool-tip)

AttributeValuesDefaultDescription
contentstring—Plain-text tooltip content (a <template data-tooltip> child wins; the trigger's title is the last fallback)
position"top", "bottom", "left", "right"—Placement; tooltips default to top, cards to bottom
delaynumber—Hover show delay in ms on the JS path (default 200; cards 300)
variant"card"—Omit for a text tooltip; card for an interactive hover card

Without CSS anchor positioning, the tooltip is placed by script: it honours position, flips when there is no room, and is centred on the trigger.

Show Delay (tool-tip)

When using <tool-tip>, control how long to wait before showing with delay. Default is 200ms.

Events & API (tool-tip)

Events

Event Description
tool-tip:show Fired when the tooltip becomes visible.
tool-tip:hide Fired when the tooltip is hidden.

JavaScript API

Method/Property Type Description
show() method Show the tooltip immediately.
hide() method Hide the tooltip immediately.
isVisible property Read-only boolean indicating if the tooltip is currently visible.

Keyboard Support

Tooltips appear on keyboard focus and can be dismissed with the Escape key (WCAG 1.4.13). Where popover="hint" is supported, Escape and light dismiss come from the Popover API. Elsewhere the tooltips fall back to popover="manual" and the script supplies Escape and click-outside dismissal itself. It does not use auto, because showing an auto popover would close any open drop-down, combo-box list or menu.

Key Action
Tab Focus the trigger element, showing the tooltip
Escape Hide the tooltip while keeping focus on the trigger

Use Tab to focus the button below, then press Escape to hide the tooltip:

Accessibility

ARIA Attributes

  • The tooltip has role="tooltip" and popover="hint"
  • The trigger gets aria-describedby pointing to the tooltip. The id is appended, so authored ids (form hints, errors) are kept, and tool-tip removes only its own id on disconnect.
  • When the title was the trigger's only name (an icon-only button), it is copied to aria-label before it is removed, and the tooltip is not also wired as a description.
  • Left and right arrows point at the trigger in right-to-left pages; in forced-colors mode the tooltip and card get a system-colour border.
  • The tooltip arrow has aria-hidden="true"
  • Uses the browser's top layer for proper stacking without z-index conflicts

Screen Reader Behavior

When the trigger receives focus, screen readers announce the element followed by the tooltip content (via aria-describedby). This provides context without requiring visual interaction.

Best Practices

  • Keep tooltip content brief and informative
  • Don't put essential information only in tooltips
  • Ensure the trigger element is focusable
  • Use tooltips for supplementary information, not primary content
  • Avoid interactive content inside tooltips (use cards instead)
↑