Overlay Window

A modal or modeless overlay.

Basic use

Radix · integration snippet
use gpui::{Context};
use xgpui_luma::controls::overlay_window::OverlayWindowEvent;
use gpui::{div, prelude::*};
use xgpui_luma_look_radix::{Look, LookControlExt};

struct Example {
    control: xgpui_luma::controls::overlay_window::OverlayWindow,
    dismissals: usize,
}

impl Example {
    fn new(cx: &mut Context<Self>) -> Self {
        // This Look extension creates a template-bound SDK overlay builder.
        let look = Look::built_in();
        let control = look
            .overlay_window("details")
            .content(|_, _, _| div().child("Details").into_any_element())
            .on_event(cx, |app, event: &OverlayWindowEvent, cx| {
                if let OverlayWindowEvent::Dismissed = event {
                    app.dismissals += 1;
                    cx.notify();
                }
            })
            .spawn(cx);

        Self { control, dismissals: 0 }
    }
}

Integration snippet, checked against the current SDK and Radix crates. cx is the initialized owner context. The control retains its callbacks; callback owners are held weakly. Render self.control.clone() in the owner’s view.

SDK behavior & customization

Configure dismissal, placement, and optional dragging. Open from an owner and preserve focus restoration.

Relevant contracts: OverlayWindowRenderModel, OverlayWindowTemplateHandlers, OverlayWindowTemplateModifier, OverlayWindowTemplateParts.

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

Events

Callbacks follow the existing SDK event stream. Registrations append, hold the owner weakly, and live until the control is released. cx.notify() requests an owner redraw. Compound payloads are borrowed; scalar values are passed by value.

Event / payloadCallback
Opened.on_opened(cx, |app, cx| { … })
Dismissed.on_dismissed(cx, |app, cx| { … })

Use .on_event(cx, |app, event, cx| { … }) for all events. Factory-created controls support the same callbacks through OverlayWindowEventExt. Existing cx.subscribe observers remain supported.

Source

SDK module · Radix adapter