Tooltip

Noninteractive help attached to a control.

Try it

Interact with the control below. This preview runs the exact code sample shown on this page.

Open example separately ↗

Basic use

Radix · integration snippet
use std::sync::{
    Arc,
    atomic::{AtomicUsize, Ordering},
};
use gpui::Context;
use xgpui_luma::controls::tooltip::{Tooltip};
use xgpui_luma::infra::{attachments::TooltipEntityExt, presenter::HasPresenter};
use xgpui_luma_look_radix as radix;

struct Example {
    button: gpui::Entity<xgpui_luma::controls::button::Button>,
    help_shown: Arc<AtomicUsize>,
}

impl Example {
    fn new(cx: &mut Context<Self>) -> Self {
        let help_shown = Arc::new(AtomicUsize::new(0));
        let counter = help_shown.clone();
        let help = Tooltip::new("Save the current document").on_shown(move || {
            counter.fetch_add(1, Ordering::Relaxed);
        });
        let button = radix::Button::new("save").solid().label("Save").spawn(cx).tooltip(help, cx);
        Self { button, help_shown }
    }
}

Integration snippet, checked against the current SDK and Radix crates. cx is the initialized owner context. Keep spawned entities and subscriptions in the owning view.

SDK behavior & customization

Use entity attachment helpers. Help describes the target without replacing its accessible label.

Relevant contracts: TooltipTemplate, TooltipRenderModel.

Use the module’s template contract for structural changes. Builder modifiers and item templates vary by control.

Events

.on_shown(|| { … }) and .on_hidden(|| { … }) filter actual presentation lifecycle events. Registrations append, including .on_event(|event| { … }). Tooltip is an attachment, so callbacks retain its existing Send + Sync contract and do not receive an application context.

Tooltip lifecycle uses Tooltip::on_event, not cx.subscribe. This callback updates application telemetry. It has no GPUI context; dispatch UI work through the application’s update mechanism. Button activation remains a separate ButtonEvent subscription.

Event / payloadApplication use
ShownThe tooltip was actually presented.
HiddenA presented tooltip ended.

TooltipEvent · Event definitions. Match the events you need; allow for other variants.

Source

SDK module · Radix adapter