hstack

Function hstack 

Source
pub fn hstack<VT: ViewTuple + 'static>(children: VT) -> impl View
Expand description

Horizontal stack of up to 128 Views in a tuple. Each item can be a different view type.

Examples found in repository?
examples/gallery.rs (lines 4-7)
3fn button_example() -> impl View {
4    hstack((
5        caption("button"),
6        button("press me", |_| println!("pressed")),
7    ))
8}
9
10fn slider_example() -> impl View {
11    hstack((caption("slider"), state(|| 0.5, |s, _| hslider(s))))
12}
13
14fn caption(s: &'static str) -> impl View {
15    s.font_size(12).padding(Auto)
16}
17
18fn knob_example() -> impl View {
19    hstack((
20        caption("knob"),
21        state(|| 0.5, |s, _| knob(s).size([30.0, 30.0]).padding(Auto)),
22    ))
23}
24
25fn toggle_example() -> impl View {
26    hstack((
27        caption("toggle"),
28        state(|| false, |s, _| toggle(s).size([30.0, 30.0]).padding(Auto)),
29    ))
30}
31
32fn text_editor_example() -> impl View {
33    hstack((
34        caption("text_editor"),
35        state(
36            || "edit me".to_string(),
37            |txt, _| text_editor(txt).padding(Auto),
38        ),
39    ))
40}
More examples
Hide additional examples
examples/clip.rs (lines 4-9)
3fn main() {
4    rui(hstack((
5        text("This text is clipped.")
6            // .offset([0.0, 0.0])
7            .clip(),
8        text("This text isn't clipped."),
9    )))
10}
examples/list.rs (line 9)
3fn main() {
4    let data = vec!["John", "Paul", "George", "Ringo"];
5
6    let ids = (0usize..data.len()).collect();
7
8    rui(list(ids, move |id| {
9        hstack((circle(), data[*id].to_string()))
10    }));
11}
examples/shapes.rs (lines 4-10)
3fn main() {
4    rui(hstack((
5        circle().color(RED_HIGHLIGHT).padding(Auto),
6        rectangle()
7            .corner_radius(5.0)
8            .color(AZURE_HIGHLIGHT)
9            .padding(Auto),
10    )));
11}
examples/nested.rs (lines 11-23)
10fn main() {
11    rui(hstack((
12        my_rectangle(),
13        vstack((
14            my_rectangle(),
15            hstack((
16                my_rectangle(),
17                vstack((
18                    my_rectangle(),
19                    hstack((my_rectangle(), vstack((my_rectangle(), my_rectangle())))),
20                )),
21            )),
22        )),
23    )));
24}
examples/todo_list.rs (lines 5-13)
3fn add_button(todos: impl Binding<Vec<String>>) -> impl View {
4    state(String::new, move |name, _| {
5        hstack((
6            text_editor(name),
7            button(text("Add Item"), move |cx| {
8                let name_str = cx[name].clone();
9                todos.with_mut(cx, |todos| todos.push(name_str));
10                // Gotta fix a bug in text_editor!
11                // cx[name] = String::new();
12            }),
13        ))
14    })
15}