pub struct ContainerStyle {Show 24 fields
pub border: Option<Border>,
pub border_sides: Option<BorderSides>,
pub border_style: Option<Style>,
pub bg: Option<Color>,
pub text_color: Option<Color>,
pub dark_bg: Option<Color>,
pub dark_border_style: Option<Style>,
pub padding: Option<Padding>,
pub margin: Option<Margin>,
pub gap: Option<u32>,
pub row_gap: Option<u32>,
pub col_gap: Option<u32>,
pub grow: Option<u16>,
pub align: Option<Align>,
pub align_self: Option<Align>,
pub justify: Option<Justify>,
pub w: Option<u32>,
pub h: Option<u32>,
pub min_w: Option<u32>,
pub max_w: Option<u32>,
pub min_h: Option<u32>,
pub max_h: Option<u32>,
pub w_pct: Option<u8>,
pub h_pct: Option<u8>,
}Expand description
Reusable container style recipe.
Define once, apply anywhere with crate::ContainerBuilder::apply. All fields
are optional — only set fields override the builder’s current values.
Styles compose: apply multiple recipes in sequence, last write wins.
§Example
use slt::{ContainerStyle, Border, Color};
const CARD: ContainerStyle = ContainerStyle::new()
.border(Border::Rounded)
.p(1)
.bg(Color::Indexed(236));
const DANGER: ContainerStyle = ContainerStyle::new()
.bg(Color::Red);
// Apply one or compose multiple:
ui.container().apply(&CARD).col(|ui| { ... });
ui.container().apply(&CARD).apply(&DANGER).col(|ui| { ... });Fields§
§border: Option<Border>Border style for the container.
border_sides: Option<BorderSides>Which sides of the border are visible.
border_style: Option<Style>Style (color and modifiers) for the border.
bg: Option<Color>Background color.
text_color: Option<Color>Foreground (text) color.
dark_bg: Option<Color>Background color in dark mode.
dark_border_style: Option<Style>Border style in dark mode.
padding: Option<Padding>Padding inside the container.
margin: Option<Margin>Margin outside the container.
gap: Option<u32>Gap between children (both row and column).
row_gap: Option<u32>Gap between rows.
col_gap: Option<u32>Gap between columns.
grow: Option<u16>Flex grow factor.
align: Option<Align>Cross-axis alignment.
align_self: Option<Align>Self alignment (overrides parent align).
justify: Option<Justify>Main-axis content distribution.
w: Option<u32>Fixed width.
h: Option<u32>Fixed height.
min_w: Option<u32>Minimum width.
max_w: Option<u32>Maximum width.
min_h: Option<u32>Minimum height.
max_h: Option<u32>Maximum height.
w_pct: Option<u8>Width as percentage of parent.
h_pct: Option<u8>Height as percentage of parent.
Implementations§
Source§impl ContainerStyle
impl ContainerStyle
Sourcepub const fn border_sides(self, sides: BorderSides) -> Self
pub const fn border_sides(self, sides: BorderSides) -> Self
Set which border sides to render.
Sourcepub const fn text_color(self, color: Color) -> Self
pub const fn text_color(self, color: Color) -> Self
Set default text color inherited by child text widgets.
Sourcepub const fn align_self(self, value: Align) -> Self
pub const fn align_self(self, value: Align) -> Self
Set per-child cross-axis alignment override.
Trait Implementations§
Source§impl Clone for ContainerStyle
impl Clone for ContainerStyle
Source§fn clone(&self) -> ContainerStyle
fn clone(&self) -> ContainerStyle
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more