pub struct Container {Show 16 fields
pub id: Option<NodeId>,
pub child: Option<Box<Node>>,
pub width: Option<f32>,
pub height: Option<f32>,
pub min_width: Option<f32>,
pub max_width: Option<f32>,
pub min_height: Option<f32>,
pub max_height: Option<f32>,
pub padding: [f32; 4],
pub flex_grow: f32,
pub flex_shrink: f32,
pub background_color: Option<Color>,
pub border_color: Option<Color>,
pub border_width: f32,
pub border_radius: f32,
pub shadow: Option<BoxShadow>,
}Expand description
The universal wrapper widget: background colour, border, padding, size constraints, and box shadow on a single child.
Container is the workhorse of layout composition. Use it whenever you
need to add visual decoration or spacing around a child widget.
§Example
Container::new(Text::new("Card body").into_node())
.bg(theme.tokens.colors.surface)
.border(theme.tokens.colors.border, 1.0)
.border_radius(8.0)
.padding_all(16.0)
.width(320.0)
.flex_grow(1.0)Fields§
§id: Option<NodeId>Explicit node identity.
child: Option<Box<Node>>The single child widget.
width: Option<f32>Fixed width in layout points.
height: Option<f32>Fixed height in layout points.
min_width: Option<f32>Minimum width constraint.
max_width: Option<f32>Maximum width constraint.
min_height: Option<f32>Minimum height constraint.
max_height: Option<f32>Maximum height constraint.
padding: [f32; 4]Padding [left, right, top, bottom].
flex_grow: f32Flex grow factor (how much extra space this container absorbs).
flex_shrink: f32Flex shrink factor (how much this container shrinks when space is tight).
background_color: Option<Color>Background fill colour.
border_color: Option<Color>Border stroke colour.
border_width: f32Border stroke width in layout points.
border_radius: f32Corner radius for rounded corners.
shadow: Option<BoxShadow>Optional drop shadow.
Implementations§
Source§impl Container
impl Container
pub fn new(child: Node) -> Self
pub fn id(self, id: NodeId) -> Self
pub fn size(self, w: f32, h: f32) -> Self
pub fn width(self, w: f32) -> Self
pub fn height(self, h: f32) -> Self
pub fn min_width(self, w: f32) -> Self
pub fn max_width(self, w: f32) -> Self
pub fn min_height(self, h: f32) -> Self
pub fn max_height(self, h: f32) -> Self
pub fn padding_all(self, p: f32) -> Self
pub fn flex_grow(self, grow: f32) -> Self
pub fn flex_shrink(self, shrink: f32) -> Self
pub fn bg(self, color: Color) -> Self
pub fn border(self, color: Color, width: f32) -> Self
pub fn border_radius(self, radius: f32) -> Self
pub fn shadow(self, shadow: BoxShadow) -> Self
pub fn into_node(self) -> Node
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Container
impl<'de> Deserialize<'de> for Container
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Lower for Container
impl Lower for Container
Source§fn lower(&self, cx: &mut LoweringContext<'_>) -> NodeId
fn lower(&self, cx: &mut LoweringContext<'_>) -> NodeId
Auto Trait Implementations§
impl Freeze for Container
impl !RefUnwindSafe for Container
impl Send for Container
impl Sync for Container
impl Unpin for Container
impl UnsafeUnpin for Container
impl !UnwindSafe for Container
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.