pub fn rectangle() -> Rectangle
Expand description
Renders a rectangle which expands to fill available space.
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)));
}
3
4
5
6
7
8
9
10
fn main() {
rui(vstack((
"This is a test.",
rectangle().flex(),
"This is another test.",
rectangle().flex(),
)));
}
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)
}));
}
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),
)));
}
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")));
}
Additional examples can be found in: