Function rui::rectangle

source ·
pub fn rectangle() -> Rectangle
Expand description

Renders a rectangle which expands to fill available space.

Examples found in repository?
examples/nested.rs (line 4)
3
4
5
6
7
8
fn my_rectangle() -> impl View {
    rectangle()
        .corner_radius(5.0)
        .color(AZURE_HIGHLIGHT)
        .padding(Auto)
}
More examples
Hide additional examples
examples/background.rs (line 6)
3
4
5
6
7
fn main() {
    rui("this is a test"
        .padding(Auto)
        .background(rectangle().corner_radius(5.0).color(AZURE_HIGHLIGHT)));
}
examples/basic.rs (line 6)
3
4
5
6
7
8
9
10
fn main() {
    rui(vstack((
        "This is a test.",
        rectangle().flex(),
        "This is another test.",
        rectangle().flex(),
    )));
}
examples/any_view.rs (line 8)
3
4
5
6
7
8
9
10
11
12
fn main() {
    rui(list(vec![7, 42], |i| {
        if *i == 7 {
            any_view(circle())
        } else {
            any_view(rectangle())
        }
        .padding(Auto)
    }));
}
examples/shapes.rs (line 6)
3
4
5
6
7
8
9
10
11
fn main() {
    rui(hstack((
        circle().color(RED_HIGHLIGHT).padding(Auto),
        rectangle()
            .corner_radius(5.0)
            .color(AZURE_HIGHLIGHT)
            .padding(Auto),
    )));
}
examples/action.rs (line 7)
5
6
7
8
9
10
11
12
13
14
15
16
fn main() {
    rui(vstack((
        rectangle()
            .tap(|_| {
                println!("rect tapped");
                MyAction {}
            })
            .padding(Auto),
        text("tap the rectangle to send an action"),
    ))
    .handle(|_, _: &MyAction| println!("action received")));
}