Function rui::hslider

source ·
pub fn hslider(value: impl Binding<f32>) -> impl SliderMods
Expand description

Horizontal slider built from other Views.

Examples found in repository?
examples/gallery.rs (line 11)
10
11
12
fn slider_example() -> impl View {
    hstack((caption("slider"), state(|| 0.5, |s, _| hslider(s))))
}
More examples
Hide additional examples
examples/slider.rs (line 13)
9
10
11
12
13
14
15
16
fn my_slider(s: impl Binding<f32>) -> impl View {
    with_ref(s, move |v| {
        vstack((
            v.to_string().font_size(10).padding(Auto),
            hslider(s).thumb_color(RED_HIGHLIGHT).padding(Auto),
        ))
    })
}
examples/lens.rs (line 14)
10
11
12
13
14
15
16
17
18
19
fn main() {
    rui(state(MyState::default, |state, cx| {
        vstack((
            cx[state].value.font_size(10).padding(Auto),
            hslider(bind(state, ValueLens {}))
                .thumb_color(RED_HIGHLIGHT)
                .padding(Auto),
        ))
    }));
}
examples/font_size.rs (line 11)
3
4
5
6
7
8
9
10
11
12
13
14
15
fn main() {
    rui(state(
        || 0.0,
        |size, cx| {
            let s = (cx[size] * 100.0) as u32;
            vstack((
                "58".font_size(s),
                format!("font size: {}", s),
                hslider(size),
            ))
        },
    ));
}