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…
Progressive enhancement tooltips: native title fallback upgraded to styled popovers with arrows and positioning.
Overview
Tooltips use a title-first progressive enhancement approach. The titleattribute 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.
Simple tooltip with title + data-tooltip
123
<!-- No JS: native browser tooltip shows "This is a tooltip!" --><!-- With JS: title removed, styled popover tooltip created --><buttontitle="This is a tooltip!"data-tooltip>Hover me</button>
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.
Tooltip position variants
1234567
<buttontitle="Tooltip appears above"data-tooltip>Top</button><buttontitle="Tooltip appears below"data-tooltipdata-tooltip-position="bottom">Bottom</button><buttontitle="Tooltip appears on the left"data-tooltipdata-tooltip-position="left">Left</button><buttontitle="Tooltip appears on the right"data-tooltipdata-tooltip-position="right">Right</button>
With Different Elements
Tooltips work on any focusable element: buttons, links, and elements with tabindex.
Tooltips on different element types
123456789101112131415
<!-- On a link --><ahref="#"title="Links can have tooltips too!"data-tooltip>Hover this link</a><!-- On an icon-only button: the title stays its name (copied to aria-label when there is no other name) --><buttontype="button"class="ghost"title="Open settings"data-tooltipdata-tooltip-position="bottom"><icon-wcname="settings"></icon-wc></button><!-- On text with tabindex --><abbrtabindex="0"title="Additional information about this feature"data-tooltip> What's this?</abbr>
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.
<buttontype="button"title="Copy to clipboard"data-tooltip="copy-tip"> Copy</button><pid="copy-tip"popover="hint"role="tooltip"> Copy to clipboard<br><small>Copied items expire after 24 hours</small><spanclass="tooltip-arrow"aria-hidden="true"></span></p>
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.
User profile hover card
123456789101112131415161718
<tool-tipvariant="card"><ahref="/user/jane"data-trigger>Jane Smith</a><sectiondata-content><layout-clusterdata-layout-gap="s"><user-avatardata-size="lg"><spandata-fallback>JS</span></user-avatar><layout-stackdata-layout-gap="xs"><strong>Jane Smith</strong><spanclass="text-muted">Senior Developer</span></layout-stack></layout-cluster><pclass="text-muted"><icon-wcname="map-pin"size="xs"></icon-wc> San Francisco· 142 contributions</p></section></tool-tip>
Link preview hover card
12345678910
<tool-tipvariant="card"><ahref="/docs/elements/native/dialog/"data-trigger>dialog element</a><sectiondata-content><strong>Dialog Element</strong><pclass="text-muted"> Native modal and non-modal dialogs with backdrop, keyboard handling, and focus management.</p></section></tool-tip>
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.
tool-tip with title fallback
12345678
<!-- Progressive enhancement: title provides no-JS fallback --><tool-tip><buttontype="button"title="Save your changes">Save</button><templatedata-tooltip><strong>Save document</strong><br><kbd>Ctrl</kbd> + <kbd>S</kbd></template></tool-tip>
For simple tooltips that don't need arrows, custom positioning, or rich content, you can skip the init script entirely. The interestforattribute (native in Chrome 142+, polyfilled in other browsers) handles hover/focus timing and popover show/hide declaratively.
Pure HTML tooltip with interestfor
12345
<!-- Pure HTML tooltip — no init script needed --><buttoninterestfor="wai-def">WAI-ARIA</button><spanid="wai-def"popover="hint"> Web Accessibility Initiative – Accessible Rich Internet Applications</span>
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:
Custom timing
1234567
/* Timing goes on the invoker, not the popover */[interestfor="wai-def"] { interest-delay-start: 300ms; interest-delay-end: 150ms;--interest-delay-start: 300ms;--interest-delay-end: 150ms;}
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.
Read-only boolean indicating if the tooltip is currently visible.
Programmatic tooltip control
12345678910
const tooltip = document.querySelector('tool-tip');// Show the tooltiptooltip.show();// Check visibilityconsole.log(tooltip.isVisible); // true// Hide the tooltiptooltip.hide();
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