Components / display
Divider builder
A soft rule between groups.
A builder is RenderOnce. Construct and mount it in one expression.
use gpui_kit::display::empty::Divider;
Reviewed in divider.
Construct
new() -> Self
Options
Chain onto the value.
id(ident: impl Into<Ident>) -> Self
label(label: impl Into<SharedString>) -> Self
axis(axis: DividerAxis) -> Self
vertical() -> Self
inset(inset: Space) -> Self
Example · divider
fn divider(_window: &mut Window, cx: &mut App) -> AnyElement {
let theme = cx.theme().clone();
stack(&theme)
.w(px(420.0))
.child(caption(&theme, "Plain"))
.child(Divider::new().id("scene.divider.plain"))
.child(caption(&theme, "Labelled, which names the group below it"))
.child(Divider::new().id("scene.divider.labelled").label("Filters"))
.child(Divider::new().id("scene.divider.archive").label("Archive"))
.child(caption(
&theme,
"Inset, for a rule inside a padded container that should not reach its \
corners",
))
.child(
div()
.column()
.w_full()
.py(px(theme.space(Space::Sm)))
.radius(&theme, Radius::Card)
.surface(&theme, Surface::Panel)
.child(
div()
.px(px(theme.space(Space::Md)))
.py(px(theme.space(Space::Xs)))
.child(crate::foundation::text(
&theme,
TypeScale::Label,
"Workspace",
)),
)
.child(Divider::new().id("scene.divider.inset").inset(Space::Md))
.child(
div()
.px(px(theme.space(Space::Md)))
.py(px(theme.space(Space::Xs)))
.child(caption(&theme, "Two rows, one rule between them")),
),
)
.child(caption(&theme, "Standing up, between two columns"))
.child(
div()
.row()
.items_stretch()
.h(px(64.0))
.w_full()
.gap(px(theme.space(Space::Md)))
.child(div().flex_1().child(caption(&theme, "Left column")))
.child(Divider::new().id("scene.divider.vertical").vertical())
.child(div().flex_1().child(caption(&theme, "Right column"))),
)
.into_any_element()
}