Function freya::components::Slider

source ·
pub fn Slider<'a>(cx: &'a Scoped<'a, SliderProps<'_>>) -> Option<VNode<'a>>
Expand description

Controlled Slider component.

You must pass a percentage from 0.0 to 100.0 and listen for value changes with onmoved and then decide if this changes are applicable, and if so, apply them.

Props

See SliderProps.

Styling

Inherits a SliderTheme theme.

Example

fn app(cx: Scope) -> Element {
    let percentage = use_state(cx, || 20.0);

    render!(
        label {
            "Value: {percentage}"
        }
        Slider {
            width: "50%",
            value: *percentage.get(),
            onmoved: |p| {
                percentage.set(p);
            }
        }
    )
}