Components / layout
Container builder
A centered, token-backed page container.
A builder is RenderOnce. Construct and mount it in one expression.
use gpui_kit::layout::Container;
Reviewed in container.
Construct
new(ident: impl Into<Ident>) -> Self
Options
Chain onto the value.
width(width: ContainerWidth) -> Self
padding(padding: Space) -> Self
child(child: impl IntoElement) -> Self
Example · container
fn container(_window: &mut Window, cx: &mut App) -> AnyElement {
let theme = cx.theme().clone();
stack(&theme)
.child(caption(
&theme,
"Page width and gutters come from the installed theme, not component-local pixels",
))
.child(
Container::new("scene.container.readable")
.width(ContainerWidth::Readable)
.child(
Card::new()
.id("scene.container.readable.card")
.padding(Space::Md)
.child(crate::foundation::text(
&theme,
TypeScale::Body,
"Readable content",
)),
),
)
.child(
Container::new("scene.container.dialog")
.width(ContainerWidth::Dialog)
.child(
Card::new()
.id("scene.container.dialog.card")
.padding(Space::Md)
.child(crate::foundation::text(
&theme,
TypeScale::Body,
"Dialog-width content",
)),
),
)
.into_any_element()
}