Skip to content

[Feature] Slider widget #153

Open

Description

@vmarcella

Overview

Add a slider widget for selecting a numeric value within a range by dragging.

Current State

No response

Scope

Goals:

  • Horizontal slider with track and thumb
  • Configurable min/max/current value
  • Drag to change value
  • Value change callback

Non-Goals:

  • Vertical slider
  • Stepped values
  • Multi-thumb

Proposed API

pub struct Slider {
  min: f32,
  max: f32,
  value: f32,
  on_change: Option<Box<dyn Fn(f32)>>,
}

impl Slider {
  pub fn new(min: f32, max: f32, initial: f32) -> Self;
  pub fn on_change(self, callback: impl Fn(f32) + 'static) -> Self;
  pub fn value(&self) -> f32;
  pub fn set_value(&mut self, value: f32);
  pub fn normalized(&self) -> f32; // 0.0 to 1.0
}

impl Widget for Slider {
  fn render(&self, ctx: &mut UiRenderContext) -> Vec<RenderCommand>;
  fn hit_test(&self, x: f32, y: f32) -> bool;
}

Acceptance Criteria

  • Slider displays track and thumb
  • Dragging thumb changes value
  • Value clamped to min/max range
  • Callback fires on value change
  • Clicking on track jumps thumb to position

Affected Crates

lambda-rs

Notes

  • Thumb position = lerp(track_start, track_end, normalized)
  • Consider touch-friendly thumb size

Activity

  1. added
    enhancement
    lambda-rs
    UI
    on Jan 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    UIenhancementlambda-rs

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions