Incular logoIncular
API ReferenceLayout Widgets

Column

Vertical flex layout with every alignment, direction, and spacing option.

Column lays children out vertically. Identical API to Row except the axis. Defaults: main_axis_alignment Start, main_axis_size Max, cross_axis_alignment Center, text_direction None (Ltr), vertical_direction Down, spacing 0.0.

Props

Prop

Type

Construction

A first Column application — 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()
                    .children(Vec::<Widget>::from([
                        Text::new("Top").into(),
                        Text::new("Middle").into(),
                        Text::new("Bottom").into(),
                    ]))
                    .main_axis_alignment(MainAxisAlignment::Center)
                    .main_axis_size(MainAxisSize::Min)
                    .cross_axis_alignment(CrossAxisAlignment::Start)
                    .spacing(8.0)
                    .build(),
            )
            .build()
            .into()
    })?;
    incular::run(app)?;
    Ok(())
}

Methods

Method calls mirror the builder: children, main_axis_alignment, main_axis_size, cross_axis_alignment (plus the alignment alias), text_direction, vertical_direction, spacing, and the get_main_axis_alignment / get_main_axis_size / get_cross_axis_alignment / get_spacing getters — see the runnable program above for every call in context.

A header/content/footer layout with an expanding middle — 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::new(Vec::<Widget>::from([
                    Text::new("Header").into(),
                    Expanded::new(Text::new("Content")).into(),
                    Text::new("Footer").into(),
                ]))
                .main_axis_alignment(MainAxisAlignment::SpaceBetween)
                .text_direction(TextDirection::Ltr)
                .vertical_direction(VerticalDirection::Down),
            )
            .build()
            .into()
    })?;
    incular::run(app)?;
    Ok(())
}

Related: Row, Flex, Expanded.

On this page