slider/
slider.rs

1use rui::*;
2
3#[derive(Default)]
4struct MyState {
5    value: f32,
6}
7
8/// A slider with a value.
9fn my_slider(s: impl Binding<f32>) -> impl View {
10    with_ref(s, move |v| {
11        vstack((
12            v.to_string().font_size(10).padding(Auto),
13            hslider(s).thumb_color(RED_HIGHLIGHT).padding(Auto),
14        ))
15    })
16}
17
18fn main() {
19    rui(state(MyState::default, |state_handle, cx| {
20        map(
21            cx[state_handle].value,
22            move |v, cx| cx[state_handle].value = v,
23            |s, _| my_slider(s),
24        )
25    }));
26}