Tooltip
Tooltip and Tooltip Group base prototypes
Base Tooltip consists of Root, Trigger, and Content. Tooltip Group is an adjacent protocol in the same family and shares delay defaults, the warm window, and active-owner coordination across Roots.
- Initial pointer hover opens after
openDelay, while reverse movement cancels the pending task. - Keyboard focus opens immediately without waiting for the pointer delay.
closeDelaylets the pointer move from Trigger into Content; Content itself must contain no focusable interaction.- Trigger additively references the
role="tooltip"Content througharia-describedbyonly while open. - Escape enters Root’s unified close request channel.
- Moving to a sibling during the Group warm window opens it immediately; the previous uncontrolled Tooltip ends perceptual presence without a visible exit overlap, and initial delay returns after
skipDelay. - Draft lifetime rule: when the current active Root unmounts or is disposed, its Group immediately returns to cold delay. Ordinary closure keeps the
skipDelaywindow. A retained open Root registers again on remount; cleanup never clears a newer active Root, and a controlled Root that refused closure is not automatically reselected.
Portal is currently owned by Content’s Overlay and renderer projection rather than a separate Base Portal prototype. Arrow remains outside the current Base guarantee until a governed geometry and positioning channel exists.
<wc-base-tooltip-group id="tooltip-group-demo">
<wc-base-tooltip-root>
<wc-base-tooltip-trigger>Account</wc-base-tooltip-trigger>
<wc-base-tooltip-content class="tooltip-content">
View account settings and profile details.
</wc-base-tooltip-content>
</wc-base-tooltip-root>
<wc-base-tooltip-root>
<wc-base-tooltip-trigger>Notifications</wc-base-tooltip-trigger>
<wc-base-tooltip-content class="tooltip-content">
Review recent alerts and notification preferences.
</wc-base-tooltip-content>
</wc-base-tooltip-root>
</wc-base-tooltip-group>
<script type="module">
document.querySelector('#tooltip-group-demo').setProps({
openDelay: 500,
closeDelay: 150,
skipDelay: 700,
});
document.querySelectorAll('.tooltip-content').forEach((content) => {
content.setProps({ side: 'top', sideOffset: 8 });
});
</script>Suggested acceptance path
Section titled “Suggested acceptance path”- Hover
Accountand confirm Tooltip appears after about 500ms; leaving early must not flash it. - With the first Tooltip open, move quickly to
Notifications; the warm sibling should open immediately and the previous Tooltip should disappear with no visible overlap. - Let both remain closed for more than 700ms, then hover again and confirm the 500ms delay returns.
- Use Tab to focus a Trigger and confirm immediate opening; Escape should close it while retaining Trigger focus.
- Switch among Web Components, React, and Vue in the toolbar and repeat the interaction.
Tooltip on a Button
Section titled “Tooltip on a Button”A focusable command and Tooltip should share one subject. Compose the draft useTooltipTrigger() authored hook with the command behavior, adapt the resulting prototype, and place that component directly inside Tooltip Root alongside Content. Do not wrap a separately focusable Button in the standalone Trigger: that creates two Tab stops.
import { definePrototype } from '@proto.ui/core';import { asButton, type ButtonProps, type ButtonExposes } from '@proto.ui/prototypes-base/button';import { useTooltipTrigger } from '@proto.ui/prototypes-base/tooltip';
export const tooltipButton = definePrototype<ButtonProps, ButtonExposes>({ name: 'app-tooltip-button', setup() { asButton(); useTooltipTrigger(); },});Button retains its role, name, click signal, disabled state and single focus owner. Tooltip adds hover/focus intent and the owned aria-describedby relation. Disabling Tooltip Root suppresses Tooltip while leaving the command available; disabling the command suppresses both. useTooltipTrigger takes no options and adds no outward exposes. It requires an existing focusable subject. Standalone asTooltipTrigger retains its original focus behavior and exposes.
For an existing styled prototype, use the same setup composition while preserving its render function: call the styled prototype’s setup(def), then useTooltipTrigger(), and return the captured render function from your definePrototype. Keep the styled prototype’s static modules declaration. This shares one host and preserves the family’s Button presentation; it is separate from the passive action-body styling used by the standalone demo below.
Tooltip is workspace source. There is no public proto-ui add target. Passing open selects controlled mode.
| Prop | Type | Default |
|---|---|---|
defaultOpen | boolean | false |
disabled | boolean | false |
openDelay | number | undefined |
closeDelay | number | undefined |
These props belong to Root. Trigger defaults disabled to false. Content accepts the Transition props and defaults side to top, align to center, sideOffset to 4, alignOffset and collisionPadding to 0 and avoidCollisions to true. Group defaults openDelay to 700, closeDelay to 100 and skipDelay to 300.