Overview
ASlider is a horizontal bar with a handle that allows users to select a single value from a range of values. The slider is generic over the numeric type (f32, i32, etc.) and supports custom step sizes.
Constructor
slider::Slider::new
Slider.
Parameters:
range- An inclusive range of possible values (e.g.,0.0..=100.0)value- The current value of the slideron_change- Function called when the slider is dragged, receives the new value
Default step: 1 unit
Builder Methods
Value Control
default
step
shift_step
Event Handlers
on_release
Layout
width
Length::Fill.
height
Appearance
style
Status
Style
Style Helpers
with_circular_handle
Examples
Basic Slider
With Custom Step
With Shift Step
With Default Value
With Release Handler
Integer Slider
Custom Width and Height
Custom Style
Volume Control Example
Interaction
The slider supports multiple interaction methods:- Click - Jump to clicked position
- Drag - Drag the handle
- Arrow keys - Fine adjustment (when hovering)
- Ctrl+Scroll / Cmd+Scroll - Adjust value with mouse wheel
- Shift - Use alternative step size
- Ctrl+Click / Cmd+Click - Reset to default value (if set)
Numeric Types
The slider works with any numeric type that implements:CopyFrom<u8>PartialOrdInto<f64>num_traits::FromPrimitive
f32, f64, i32, i64, u32, u64
Related
Text Input
For precise numeric entry
Button
For discrete choices
