Incular logoIncular
API ReferenceLayout Widgets

SizedBox

Fixed-size box and pure spacer with every constructor.

SizedBox { width, height, child } — all None by default (unconstrained passthrough). Prefer it over Container for pure spacers.

Props

Prop

Type

Construction

Fixed gaps and boxes — copy, paste, and run:

use incular::prelude::*;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let app = Application::new(|_cx| {
        Container::builder()
            .padding(EdgeInsets::all(24.0))
            .alignment(Alignment::CENTER)
            .child(
                Column::builder()
                    .main_axis_size(MainAxisSize::Min)
                    .spacing(8.0)
                    .children(Vec::<Widget>::from([
                        SizedBox::new().width(120.0).height(40.0).into(),
                        SizedBox::square(48.0).into(),
                        SizedBox::shrink().into(),
                    ]))
                    .build(),
            )
            .build()
            .into()
    })?;
    incular::run(app)?;
    Ok(())
}

SizedBox::expand(), from_size(Size), and from_dimensions(w, h, child) cover the rest; see the Props table above.

Methods

pub const fn new() -> Self
pub fn from_dimensions(width: Option<f32>, height: Option<f32>, child: Option<impl Into<Widget>>) -> Self
pub fn child(mut self, child: impl Into<Widget>) -> Self
pub fn width(mut self, width: f32) -> Self
pub fn height(mut self, height: f32) -> Self
pub fn square(dimension: f32) -> Self
pub fn from_size(size: Size) -> Self
pub const fn shrink() -> Self
pub const fn expand() -> Self
pub fn empty() -> Self

Related: ConstrainedBox.

On this page