Skip to content

Component Slider

MeowLynxSea edited this page Jun 18, 2026 · 5 revisions

Slider

A horizontal slider for selecting a value within a range. Drag is wired internally — no caller drag handler needed.

use yororen_ui::headless::slider::slider;

slider("volume", cx)
    .value(self.volume)
    .range(0.0, 100.0)
    .step(1.0)
    .on_change({
        let entity = cx.entity();
        move |new, _, cx| entity.update(cx, |s, _| s.volume = new);
    })
    .render(cx)

Props

Method Purpose
value(v) Current value (clamped to [min, max]).
range(min, max) Min and max of the track.
step(s) Step size; the renderer snaps drag to multiples of s.
disabled(v) Disable the drag handler.
on_change(closure) Fn(f32, &mut Window, &mut App) + 'static + Send + Sync. Fires continuously during drag.

Factory takes (id, _cx). .render(cx) returns Stateful<Div>. No state entity.

See also: NumberInput, ProgressBar.

Clone this wiki locally