pub struct Container {Show 18 fields
pub background: Option<Color>,
pub gradient: Option<(Color, Color, bool)>,
pub border_color: Option<Color>,
pub border_width: f32,
pub border_radius: f32,
pub shape: BoxShape,
pub shadow_blur: f32,
pub shadow_color: Color,
pub padding: EdgeInsets,
pub margin: EdgeInsets,
pub width: Option<f32>,
pub height: Option<f32>,
pub min_width: f32,
pub min_height: f32,
pub clip: bool,
pub align: Option<Alignment>,
pub material: Option<ShaderMaterial>,
pub child: Option<BoxedWidget>,
}Expand description
The most fundamental building block — a maximally-configurable box: shape, background (solid or gradient), border, shadow, corner radius, padding, margin, fixed/min size, alignment, child clipping, and a child.
Everything box-shaped is a Container — there is no ColoredBox / CircleBox
/ GradientBox (D095). Analogous to a CSS div or Flutter’s Container.
Fields§
§background: Option<Color>§gradient: Option<(Color, Color, bool)>§border_color: Option<Color>§border_width: f32§border_radius: f32§shape: BoxShape§shadow_blur: f32§shadow_color: Color§padding: EdgeInsets§margin: EdgeInsets§width: Option<f32>§height: Option<f32>§min_width: f32§min_height: f32§clip: bool§align: Option<Alignment>§material: Option<ShaderMaterial>§child: Option<BoxedWidget>Implementations§
Source§impl Container
impl Container
pub fn new() -> Self
pub fn align(self, a: Alignment) -> Self
pub fn background(self, c: Color) -> Self
Sourcepub fn gradient(self, from: Color, to: Color) -> Self
pub fn gradient(self, from: Color, to: Color) -> Self
Two-stop linear gradient background (overrides solid background).
pub fn gradient_h(self, from: Color, to: Color) -> Self
pub fn border(self, c: Color, w: f32) -> Self
pub fn radius(self, r: f32) -> Self
pub fn shape(self, s: BoxShape) -> Self
pub fn circle(self) -> Self
pub fn stadium(self) -> Self
pub fn shadow(self, color: Color, blur: f32) -> Self
Sourcepub fn elevation(self, e: f32) -> Self
pub fn elevation(self, e: f32) -> Self
Material-style elevation shortcut (black shadow scaled by elevation).
pub fn padding(self, p: EdgeInsets) -> Self
pub fn margin(self, m: EdgeInsets) -> Self
pub fn width(self, w: f32) -> Self
pub fn height(self, h: f32) -> Self
pub fn size(self, w: f32, h: f32) -> Self
pub fn min_size(self, w: f32, h: f32) -> Self
pub fn child(self, w: impl Widget + 'static) -> Self
Sourcepub fn material(self, m: ShaderMaterial) -> Self
pub fn material(self, m: ShaderMaterial) -> Self
Per-instance shader material — replaces the background fill (gradient/
solid) when resolved. Beats the theme’s ContainerMaterial default.
Corners are drawn square under the shader (no rounded-clip primitive
yet, D124 Step 4+); border/shadow/child/radius are unaffected.
Trait Implementations§
Source§impl Widget for Container
impl Widget for Container
Source§fn layout(&self, ctx: &LayoutCtx<'_>) -> Size
fn layout(&self, ctx: &LayoutCtx<'_>) -> Size
ctx.constraints and return a size within them. Read more