Components / navigation
Collapsible builder
A single region behind a header that opens and shuts it.
A builder is RenderOnce. Construct and mount it in one expression.
use gpui_kit::navigation::Collapsible;
Reviewed in collapsible.
Construct
new(ident: impl Into<Ident>, title: impl Into<SharedString>) -> Self
header_id(ident: &Ident) -> SharedString
Options
Chain onto the value.
description(description: impl Into<SharedString>) -> Self
open(open: bool) -> Self
disabled(disabled: bool) -> Self
body(body: impl IntoElement) -> Self
on_toggle(handler: impl Fn(bool, &mut Window, &mut App) + 'static) -> Self
Example · collapsible
fn collapsible(_window: &mut Window, cx: &mut App) -> AnyElement {
let theme = cx.theme().clone();
stack(&theme)
.w(px(520.0))
.child(
Collapsible::new("scene.collapsible.open", "Advanced")
.description("Settings most runs never touch")
.open(true)
.body(crate::foundation::text(
&theme,
TypeScale::Body,
"Requests go out over the system proxy.",
))
.on_toggle(|_, _, _| {}),
)
.child(
Collapsible::new("scene.collapsible.shut", "Diagnostics")
.description("Nothing is collected until this is opened")
.body(crate::foundation::text(
&theme,
TypeScale::Body,
"This body is absent from the tree while it is shut.",
))
.on_toggle(|_, _, _| {}),
)
.child(
Collapsible::new("scene.collapsible.refused", "Managed by policy")
.description("This machine cannot change these")
.disabled(true)
.body(crate::foundation::text(
&theme,
TypeScale::Body,
"Set by the administrator.",
)),
)
.into_any_element()
}