pub struct ContainerBuilder<'a> { /* private fields */ }Expand description
Fluent builder for configuring containers before calling .col() or .row().
Obtain one via Context::container or Context::bordered. Chain the
configuration methods you need, then finalize with .col(|ui| { ... }) or
.row(|ui| { ... }).
§Example
use slt::{Border, Color};
ui.container()
.border(Border::Rounded)
.pad(1)
.grow(1)
.col(|ui| {
ui.text("inside a bordered, padded, growing column");
});Implementations§
Source§impl<'a> ContainerBuilder<'a>
impl<'a> ContainerBuilder<'a>
Sourcepub fn apply(self, style: &ContainerStyle) -> Self
pub fn apply(self, style: &ContainerStyle) -> Self
Apply a reusable ContainerStyle recipe. Only set fields override
the builder’s current values. Chain multiple .apply() calls to compose.
Sourcepub fn border_top(self, show: bool) -> Self
pub fn border_top(self, show: bool) -> Self
Show or hide the top border.
Sourcepub fn border_right(self, show: bool) -> Self
pub fn border_right(self, show: bool) -> Self
Show or hide the right border.
Sourcepub fn border_bottom(self, show: bool) -> Self
pub fn border_bottom(self, show: bool) -> Self
Show or hide the bottom border.
Sourcepub fn border_left(self, show: bool) -> Self
pub fn border_left(self, show: bool) -> Self
Show or hide the left border.
Sourcepub fn border_sides(self, sides: BorderSides) -> Self
pub fn border_sides(self, sides: BorderSides) -> Self
Set which border sides are visible.
Sourcepub fn border_style(self, style: Style) -> Self
pub fn border_style(self, style: Style) -> Self
Set the style applied to the border characters.
Sourcepub fn dark_border_style(self, style: Style) -> Self
pub fn dark_border_style(self, style: Style) -> Self
Border style used when dark mode is active.
pub fn bg(self, color: Color) -> Self
Sourcepub fn group_hover_bg(self, color: Color) -> Self
pub fn group_hover_bg(self, color: Color) -> Self
Background color applied when the parent group is hovered.
Sourcepub fn group_hover_border_style(self, style: Style) -> Self
pub fn group_hover_border_style(self, style: Style) -> Self
Border style applied when the parent group is hovered.
pub fn w_at(self, bp: Breakpoint, value: u32) -> Self
pub fn h_at(self, bp: Breakpoint, value: u32) -> Self
Sourcepub fn min_w(self, value: u32) -> Self
pub fn min_w(self, value: u32) -> Self
Set the minimum width constraint. Shorthand for min_width.
Sourcepub fn xs_min_w(self, value: u32) -> Self
pub fn xs_min_w(self, value: u32) -> Self
Minimum width applied only at Xs breakpoint (< 40 cols).
Sourcepub fn sm_min_w(self, value: u32) -> Self
pub fn sm_min_w(self, value: u32) -> Self
Minimum width applied only at Sm breakpoint (40-79 cols).
Sourcepub fn md_min_w(self, value: u32) -> Self
pub fn md_min_w(self, value: u32) -> Self
Minimum width applied only at Md breakpoint (80-119 cols).
Sourcepub fn lg_min_w(self, value: u32) -> Self
pub fn lg_min_w(self, value: u32) -> Self
Minimum width applied only at Lg breakpoint (120-159 cols).
Sourcepub fn xl_min_w(self, value: u32) -> Self
pub fn xl_min_w(self, value: u32) -> Self
Minimum width applied only at Xl breakpoint (>= 160 cols).
pub fn min_w_at(self, bp: Breakpoint, value: u32) -> Self
Sourcepub fn max_w(self, value: u32) -> Self
pub fn max_w(self, value: u32) -> Self
Set the maximum width constraint. Shorthand for max_width.
Sourcepub fn xs_max_w(self, value: u32) -> Self
pub fn xs_max_w(self, value: u32) -> Self
Maximum width applied only at Xs breakpoint (< 40 cols).
Sourcepub fn sm_max_w(self, value: u32) -> Self
pub fn sm_max_w(self, value: u32) -> Self
Maximum width applied only at Sm breakpoint (40-79 cols).
Sourcepub fn md_max_w(self, value: u32) -> Self
pub fn md_max_w(self, value: u32) -> Self
Maximum width applied only at Md breakpoint (80-119 cols).
Sourcepub fn lg_max_w(self, value: u32) -> Self
pub fn lg_max_w(self, value: u32) -> Self
Maximum width applied only at Lg breakpoint (120-159 cols).
Sourcepub fn xl_max_w(self, value: u32) -> Self
pub fn xl_max_w(self, value: u32) -> Self
Maximum width applied only at Xl breakpoint (>= 160 cols).
pub fn max_w_at(self, bp: Breakpoint, value: u32) -> Self
Sourcepub fn min_h(self, value: u32) -> Self
pub fn min_h(self, value: u32) -> Self
Set the minimum height constraint. Shorthand for min_height.
Sourcepub fn max_h(self, value: u32) -> Self
pub fn max_h(self, value: u32) -> Self
Set the maximum height constraint. Shorthand for max_height.
Sourcepub fn min_height(self, value: u32) -> Self
pub fn min_height(self, value: u32) -> Self
Set the minimum height constraint in rows.
Sourcepub fn max_height(self, value: u32) -> Self
pub fn max_height(self, value: u32) -> Self
Set the maximum height constraint in rows.
Sourcepub fn h_pct(self, pct: u8) -> Self
pub fn h_pct(self, pct: u8) -> Self
Set height as a percentage (1-100) of the parent container.
Sourcepub fn constraints(self, constraints: Constraints) -> Self
pub fn constraints(self, constraints: Constraints) -> Self
Set all size constraints at once using a Constraints value.
pub fn gap_at(self, bp: Breakpoint, value: u32) -> Self
Sourcepub fn grow(self, grow: u16) -> Self
pub fn grow(self, grow: u16) -> Self
Set the flex-grow factor. 1 means the container expands to fill available space.
Sourcepub fn xs_grow(self, value: u16) -> Self
pub fn xs_grow(self, value: u16) -> Self
Grow factor applied only at Xs breakpoint (< 40 cols).
Sourcepub fn sm_grow(self, value: u16) -> Self
pub fn sm_grow(self, value: u16) -> Self
Grow factor applied only at Sm breakpoint (40-79 cols).
Sourcepub fn md_grow(self, value: u16) -> Self
pub fn md_grow(self, value: u16) -> Self
Grow factor applied only at Md breakpoint (80-119 cols).
Sourcepub fn lg_grow(self, value: u16) -> Self
pub fn lg_grow(self, value: u16) -> Self
Grow factor applied only at Lg breakpoint (120-159 cols).
Sourcepub fn xl_grow(self, value: u16) -> Self
pub fn xl_grow(self, value: u16) -> Self
Grow factor applied only at Xl breakpoint (>= 160 cols).
pub fn grow_at(self, bp: Breakpoint, value: u16) -> Self
Sourcepub fn xs_p(self, value: u32) -> Self
pub fn xs_p(self, value: u32) -> Self
Uniform padding applied only at Xs breakpoint (< 40 cols).
Sourcepub fn sm_p(self, value: u32) -> Self
pub fn sm_p(self, value: u32) -> Self
Uniform padding applied only at Sm breakpoint (40-79 cols).
Sourcepub fn md_p(self, value: u32) -> Self
pub fn md_p(self, value: u32) -> Self
Uniform padding applied only at Md breakpoint (80-119 cols).
Sourcepub fn lg_p(self, value: u32) -> Self
pub fn lg_p(self, value: u32) -> Self
Uniform padding applied only at Lg breakpoint (120-159 cols).
Sourcepub fn xl_p(self, value: u32) -> Self
pub fn xl_p(self, value: u32) -> Self
Uniform padding applied only at Xl breakpoint (>= 160 cols).
pub fn p_at(self, bp: Breakpoint, value: u32) -> Self
Sourcepub fn center(self) -> Self
pub fn center(self) -> Self
Center children on the cross axis. Shorthand for .align(Align::Center).
Sourcepub fn space_between(self) -> Self
pub fn space_between(self) -> Self
Distribute children with equal space between; first at start, last at end.
Sourcepub fn space_around(self) -> Self
pub fn space_around(self) -> Self
Distribute children with equal space around each child.
Sourcepub fn space_evenly(self) -> Self
pub fn space_evenly(self) -> Self
Distribute children with equal space between all children and edges.
Sourcepub fn title(self, title: impl Into<String>) -> Self
pub fn title(self, title: impl Into<String>) -> Self
Set a plain-text title rendered in the top border.
Sourcepub fn title_styled(self, title: impl Into<String>, style: Style) -> Self
pub fn title_styled(self, title: impl Into<String>, style: Style) -> Self
Set a styled title rendered in the top border.
Sourcepub fn scroll_offset(self, offset: u32) -> Self
pub fn scroll_offset(self, offset: u32) -> Self
Set the vertical scroll offset in rows. Used internally by Context::scrollable.
Sourcepub fn col(self, f: impl FnOnce(&mut Context)) -> Response
pub fn col(self, f: impl FnOnce(&mut Context)) -> Response
Finalize the builder as a vertical (column) container.
The closure receives a &mut Context for rendering children.
Returns a Response with click/hover state for this container.
Sourcepub fn row(self, f: impl FnOnce(&mut Context)) -> Response
pub fn row(self, f: impl FnOnce(&mut Context)) -> Response
Finalize the builder as a horizontal (row) container.
The closure receives a &mut Context for rendering children.
Returns a Response with click/hover state for this container.
Sourcepub fn line(self, f: impl FnOnce(&mut Context)) -> Response
pub fn line(self, f: impl FnOnce(&mut Context)) -> Response
Finalize the builder as an inline text line.
Like row but gap is forced to zero
for seamless inline rendering of mixed-style text.
Sourcepub fn draw(self, f: impl FnOnce(&mut Buffer, Rect) + 'static)
pub fn draw(self, f: impl FnOnce(&mut Buffer, Rect) + 'static)
Finalize the builder as a raw-draw region with direct buffer access.
The closure receives (&mut Buffer, Rect) after layout is computed.
Use buf.set_char(), buf.set_string(), buf.get_mut() to write
directly into the terminal buffer. Writes outside rect are clipped.
The closure must be 'static because it is deferred until after layout.
To capture local data, clone or move it into the closure:
let data = my_vec.clone();
ui.container().w(40).h(20).draw(move |buf, rect| {
// use `data` here
});