Incular logoIncular
API ReferenceLayout Widgets

Stack

Overlay layout painting children in order with alignment and clipping.

Stack overlays children in paint order. Alignment is absolute (left/right — no text direction needed). Defaults: alignment = TOP_LEFT, fit = Loose, clip_behavior = HardEdge.

Props

Prop

Type

Construction

An overlay card with a badge — copy, paste, and run:

use incular::prelude::*;
use incular::config::{Clip, StackFit};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let app = Application::new(|_cx| {
        Container::builder()
            .padding(EdgeInsets::all(24.0))
            .alignment(Alignment::CENTER)
            .child(
                Stack::builder()
                    .children(Vec::<Widget>::from([
                        Container::new()
                            .color(Color::WHITE)
                            .width(200.0)
                            .height(200.0).into(),
                        Positioned::new(Text::new("Badge"))
                            .top(8.0)
                            .right(8.0).into(),
                    ]))
                    .alignment(Alignment::CENTER)
                    .fit(StackFit::Expand)
                    .clip_behavior(Clip::HardEdge)
                    .build(),
            )
            .build()
            .into()
    })?;
    incular::run(app)?;
    Ok(())
}

Methods

pub fn new(children: impl IntoIterator<Item = impl Into<Widget>>) -> Self
pub fn aligned(alignment: Alignment, children: impl IntoIterator<Item = impl Into<Widget>>) -> Self
pub fn alignment(mut self, alignment: Alignment) -> Self
pub fn fit(mut self, fit: StackFit) -> Self
pub fn clip_behavior(mut self, clip: Clip) -> Self
pub fn get_alignment(&self) -> Alignment
pub fn get_fit(&self) -> StackFit
pub fn get_clip_behavior(&self) -> Clip

StackFit: Loose (default) / Expand / Passthrough. See Clip.

Related: Positioned, IndexedStack, Overlay.

On this page