GPUI Box GitHub

Components / overlay

Overlay builder

A floating surface.

A builder is RenderOnce. Construct and mount it in one expression.

use gpui_kit::overlay::Overlay;

Reviewed in overlay.

Construct
new(ident: impl Into<Ident>) -> Self
modal(ident: impl Into<Ident>) -> Self
edge(ident: impl Into<Ident>, edge: Edge) -> Self
Options

Chain onto the value.

layer(layer: Layer) -> Self
stack(depth: usize) -> Self
placement(placement: Placement) -> Self
hang(hang: Hang) -> Self
window_snap_margin(margin: Pixels) -> Self
scrim(scrim: bool) -> Self
progress(progress: f32) -> Self
child(content: impl IntoElement) -> Self
on_dismiss(handler: impl Fn(&mut Window, &mut App) + 'static) -> Self
Example · overlay
fn overlay(_window: &mut Window, cx: &mut App) -> AnyElement {
    let theme = cx.theme().clone();
    stack(&theme)
        .w(px(520.0))
        .h(px(320.0))
        .child(page_behind(&theme, "Workspace settings"))
        .child(
            Overlay::modal("scene.overlay.dialog")
                .placement(Placement::Center)
                .child(
                    crate::overlay::surface(
                        "scene.overlay.surface",
                        &theme,
                        crate::overlay::OverlaySurface::MODAL,
                    )
                    .w(px(320.0))
                    .p(px(theme.spacing.lg))
                    .gap(px(theme.spacing.sm))
                    .child(crate::foundation::text(
                        &theme,
                        TypeScale::Subtitle,
                        "Delete this workspace?",
                    ))
                    .child(
                        crate::foundation::text(
                            &theme,
                            TypeScale::Body,
                            "Its runs, filters and saved views are removed for everyone. This \
                                 cannot be undone.",
                        )
                        .text_tone(&theme, TextTone::Muted),
                    )
                    .child(
                        div()
                            .row()
                            .justify_end()
                            .gap(px(theme.spacing.sm))
                            .child(
                                Button::new("scene.overlay.cancel")
                                    .label("Cancel")
                                    .secondary()
                                    .on_click(|_, _| {}),
                            )
                            .child(
                                Button::new("scene.overlay.confirm")
                                    .label("Delete")
                                    .danger()
                                    .on_click(|_, _| {}),
                            ),
                    ),
                ),
        )
        .into_any_element()
}

Source: crates/gpui-kit/src/overlay/layer.rs