Components / layout
DesktopTitlebar builder
A client-rendered desktop titlebar with native window-control hit testing.
A builder is RenderOnce. Construct and mount it in one expression.
use gpui_kit::layout::DesktopTitlebar;
Reviewed in desktop-titlebar.
Construct
new(ident: impl Into<Ident>, title: impl Into<SharedString>) -> Self
Options
Chain onto the value.
subtitle(subtitle: impl Into<SharedString>) -> Self
left(content: impl IntoElement) -> Self
right(content: impl IntoElement) -> Self
button_layout(layout: WindowButtonLayout) -> Self
controls(controls: WindowControls) -> Self
on_event(handler: impl Fn(DesktopTitlebarEvent, &mut Window, &mut App) + 'static) -> Self
Reports
The variants of the event it emits. It never applies the change itself.
- Minimize
- ToggleMaximize
- Close
Example · desktop-titlebar
fn desktop_titlebar(_window: &mut Window, cx: &mut App) -> AnyElement {
let theme = cx.theme().clone();
stack(&theme)
.w(px(720.0))
.child(
div()
.surface(&theme, Surface::Panel)
.radius(&theme, Radius::Card)
.overflow_hidden()
.child(
DesktopTitlebar::new("scene.desktop-titlebar", "Workspace")
.subtitle("main.rs")
.left(
Button::new("scene.desktop-titlebar.workspace")
.label("Workspace menu")
.ghost()
.small()
.on_click(|_, _| {}),
)
.right(
Badge::new("Connected")
.success()
.id("scene.desktop-titlebar.status"),
)
.on_event(|_, _, _| {}),
)
.child(div().h(px(112.0)).p_token(&theme, Space::Lg).child(caption(
&theme,
"Host content is client input; maximize remains native Snap chrome.",
))),
)
.into_any_element()
}