bezel

Components / Presentation

Tooltip

Markdown crates/ui/src/tooltip.rs docs.rs

use ui::tooltip::Tooltip;

div()
    .id("copy")
    .tooltip(|window, cx| Tooltip::text("Copy path", window, cx))
    .child("⌘C")

An entity rather than a plain function: gpui's .tooltip(..) takes a builder returning an AnyView, since the tooltip is mounted in its own layer after the hover delay.

With a shortcut

Tooltip::with_keystroke("Copy path", "⌘C", window, cx)

API

impl Tooltip {
    /// The label.
    pub fn text(text: impl Into<SharedString>, window: &mut Window, cx: &mut App) -> AnyView;

    /// Shortcut right-aligned in the same card.
    pub fn with_keystroke(
        text: impl Into<SharedString>,
        keystroke: impl Into<SharedString>,
        window: &mut Window,
        cx: &mut App,
    ) -> AnyView;

    // ...
}

The delay is gpui's — .tooltip_show_delay(..) on the element changes it.

Tooltip