Skip to main content

ContainerStyle

Struct ContainerStyle 

Source
pub struct ContainerStyle {
Show 20 fields pub border: Option<Border>, pub border_sides: Option<BorderSides>, pub border_style: Option<Style>, pub bg: 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 grow: Option<u16>, pub align: 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 [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_sides: Option<BorderSides>§border_style: Option<Style>§bg: Option<Color>§dark_bg: Option<Color>§dark_border_style: Option<Style>§padding: Option<Padding>§margin: Option<Margin>§gap: Option<u32>§grow: Option<u16>§align: Option<Align>§justify: Option<Justify>§w: Option<u32>§h: Option<u32>§min_w: Option<u32>§max_w: Option<u32>§min_h: Option<u32>§max_h: Option<u32>§w_pct: Option<u8>§h_pct: Option<u8>

Implementations§

Source§

impl ContainerStyle

Source

pub const fn new() -> Self

Create an empty container style with no overrides.

Source

pub const fn border(self, border: Border) -> Self

Set the border style.

Source

pub const fn border_sides(self, sides: BorderSides) -> Self

Set which border sides to render.

Source

pub const fn bg(self, color: Color) -> Self

Set the background color.

Source

pub const fn dark_bg(self, color: Color) -> Self

Set the dark-mode background color.

Source

pub const fn p(self, value: u32) -> Self

Set uniform padding on all sides.

Source

pub const fn px(self, value: u32) -> Self

Set horizontal padding.

Source

pub const fn py(self, value: u32) -> Self

Set vertical padding.

Source

pub const fn m(self, value: u32) -> Self

Set uniform margin on all sides.

Source

pub const fn gap(self, value: u32) -> Self

Set the gap between children.

Source

pub const fn grow(self, value: u16) -> Self

Set the flex-grow factor.

Source

pub const fn w(self, value: u32) -> Self

Set fixed width.

Source

pub const fn h(self, value: u32) -> Self

Set fixed height.

Source

pub const fn min_w(self, value: u32) -> Self

Set minimum width.

Source

pub const fn max_w(self, value: u32) -> Self

Set maximum width.

Source

pub const fn align(self, value: Align) -> Self

Set cross-axis alignment.

Source

pub const fn justify(self, value: Justify) -> Self

Set main-axis justification.

Source

pub const fn min_h(self, value: u32) -> Self

Set minimum height.

Source

pub const fn max_h(self, value: u32) -> Self

Set maximum height.

Source

pub const fn w_pct(self, value: u8) -> Self

Set width as percentage of parent (1-100).

Source

pub const fn h_pct(self, value: u8) -> Self

Set height as percentage of parent (1-100).

Trait Implementations§

Source§

impl Clone for ContainerStyle

Source§

fn clone(&self) -> ContainerStyle

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ContainerStyle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ContainerStyle

Source§

fn default() -> ContainerStyle

Returns the “default value” for a type. Read more
Source§

impl Copy for ContainerStyle

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.