Overlays

Tooltip

Contextual information shown on hover or focus.

Rust
1use herogpui::components::tooltip::Tooltip;

Usage

Rust
1use herogpui::prelude::{Button, Tooltip, Variant};
2use gpui::prelude::*;
3use gpui::px;
4
5row(vec![
6    Tooltip::new("With an arrow")
7        .show_arrow(true)
8        // `offset` is the gap between trigger and panel.
9        .offset(px(10.))
10        .child(
11            Button::new("tooltip-arrow-on")
12                .label("Arrow")
13                .variant(Variant::Secondary),
14        )
15        .into_any_element(),
16    Tooltip::new("Without one")
17        .show_arrow(false)
18        .child(
19            Button::new("tooltip-arrow-off")
20                .label("No arrow")
21                .variant(Variant::Secondary),
22        )
23        .into_any_element(),
24])

Live HeroGPUI compiled to WebAssembly. Select any example without loading another WASM instance.

Anatomy

Rust types

Tooltip

Tooltip is assembled from these builders. The API reference lists each one.

Customization

Appearance builders and theme tokens Tooltip uses.

Styling

Tooltip styling
StyleDescription
p(px(8.)) + small_radiusEight-pixel inset and the 12px small radius.
overlay colors + 12/16px + overlay_shadow/overlay_hairlineOverlay colours, 12/16px type and overlay shadow, plus the dark-mode overlay hairline.
shaped max-content width clamped to px(320.)Uses max-content width up to Tailwind's xs cap.
default WhiteSpace::NormalRestores normal wrapping but GPUI has no break-all mode for a single unbroken token.
Motion::POPOVER_IN + entering_zoomFade and zoom match; transform origin and placement slide are absent.
Motion::LIST_OUT + exitingExit motion matches.
TOOLTIP_ARROW size(px(12.)) + overlay background + arrow_rotationSize, geometry, fill and rotation match; GPUI's single-colour SVG tint cannot add the separate 40% border stroke.
wrapper relative flex + hover/focus listenersThe focus wrapper exists, but GPUI has no inline-block display and the three property transitions are not animated.
contains_focused + child focus treatmentThe wrapper tracks descendant focus to open the tip, but the caller-provided child owns the visible focus ring.
layout.tooltip_delay_msTheme default before a hovered tooltip opens.
layout.tooltip_close_delay_msTheme default before a tooltip closes after hover leaves.
offset.unwrap_or(show_arrow ? 7 : 3)Pinned Tooltip.Content default offset logic.
TooltipPlacement matchTip anchoring and arrow rotation for the four cardinals.
reduce_motion + should_skip_animationReduced motion and the explicit skip both leave the tip fully visible without geometric animation.

API reference

Builders

Tooltip builders
BuilderTypeDefaultDescription
new(content) + ParentElement::extendAnyElementTrigger and content composition; takes tip text positionally and trigger children through ParentElement.
delay(u64)u641500The pinned docs table says 700; v3.2.4 runtime resolves 1500 from --tooltip-delay, matching pinned 's default.
close_delay(u64)u64500The pinned docs table says zero; v3.2.4 runtime resolves 500 from --tooltip-close-delay, matching pinned 's default.
trigger(TooltipTrigger)TooltipTriggerTooltipTrigger::HoverHover also answers keyboard focus; Focus ignores pointer hover.
is_disabled(bool)boolfalseSuppresses the tooltip while leaving its trigger content rendered.
should_skip_animation(bool)boolfalseShows and hides without the tooltip animation wrapper.
new(content)contentTooltip body content; accepts text rather than arbitrary elements.
show_arrow(bool)boolfalseDraws the built-in curved arrow.
offset(Pixels)Pixels3 (7 with arrow)Distance from the trigger, including v3's arrow-aware default.
placement(TooltipPlacement)TooltipPlacementTooltipPlacement::TopThe four cardinal placements render; RAC's start/end and edge variants are not represented.
ParentElement::extendAnyElementTrigger content is composed as the Tooltip's child, but does not expose a separately replaceable trigger part.

Parts

Tooltip parts
PartDescription
TooltipState owner for delay, trigger mode and open lifecycle.
TooltipHover/focus wrapper around caller-provided trigger content; GPUI has no inline-block display mode.
TooltipFloating overlay surface containing the tooltip text.
TooltipOptional 12px curved arrow; custom arrow content and the separate 40% border stroke are unavailable.

States

Tooltip states
BuilderStateDescription
TooltipManager + prepare_tooltip_open + start_tooltip_cooldownGlobal sequenceOnly one tooltip stays open; the first hover waits for delay, later hovers during max(500ms, closeDelay) cooldown open immediately, and the sequence becomes cold again after cooldown.
overlay_phase Entering + entering_zoom(POPOVER_IN)Entering150ms Smooth fade and zoom from 90%; v3's placement-specific 4px translation is not reproduced.
overlay_phase Exiting + exiting(LIST_OUT)Exiting100ms Smooth fade and zoom to 95%.
TooltipPlacement matchPlacementCardinal positioning and arrow rotation; start/end variants and attributes are absent.