Incular logoIncular
API ReferenceLayout Widgets

Center

Center a child within itself with optional size factors.

Center is a thin wrapper lowering to Align::CENTER, preserving factors. Factors default None, clamped to max(0.0).

Props

Prop

Type

use incular::prelude::*;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let app = Application::new(|_cx| {
        Container::builder()
            .padding(EdgeInsets::all(24.0))
            .child(Center::new(Text::new("Centered")).width_factor(2.0))
            .build()
            .into()
    })?;
    incular::run(app)?;
    Ok(())
}

Methods

pub fn new(child: impl Into<Widget>) -> Self
pub fn width_factor(mut self, factor: f32) -> Self
pub fn height_factor(mut self, factor: f32) -> Self

Related: Align, Container.

On this page