Incular logoIncular
API ReferenceLayout Widgets

Positioned

Absolute edge positioning of a child inside a Stack.

Positioned places a child inside a Stack via edge offsets plus optional explicit size. All offsets default None.

Props

Prop

Type

Construction

Fill, corner, and fixed-size placements — 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(
                Stack::builder()
                    .children(Vec::<Widget>::from([
                        Container::new()
                            .color(Color::WHITE)
                            .width(240.0)
                            .height(160.0).into(),
                        Positioned::fill(Text::new("Fill")).into(),
                        Positioned::new(Text::new("Badge"))
                            .right(12.0)
                            .bottom(12.0)
                            .width(96.0)
                            .height(32.0).into(),
                    ]))
                    .build(),
            )
            .build()
            .into()
    })?;
    incular::run(app)?;
    Ok(())
}

## Methods

```rust
pub fn new(child: impl Into<Widget>) -> Self
pub fn fill(child: impl Into<Widget>) -> Self // left=top=right=bottom=0.0
pub fn left(mut self, left: f32) -> Self
pub fn top(mut self, top: f32) -> Self
pub fn right(mut self, right: f32) -> Self
pub fn bottom(mut self, bottom: f32) -> Self
pub fn width(mut self, width: f32) -> Self
pub fn height(mut self, height: f32) -> Self

Combine opposite edges to stretch, or one edge plus an explicit size to pin (see the runnable program above for both patterns).

Related: Stack.

On this page