SliderControl

March 15, 2026 · View on GitHub

A single-value slider control that allows users to select a value from a range by dragging a thumb along a track. Supports horizontal and vertical orientations, keyboard and mouse interaction, and optional value and min/max labels.

Properties

PropertyTypeDefaultDescription
Valuedouble0Current value, clamped to [MinValue, MaxValue] and snapped to Step
MinValuedouble0Minimum value of the range
MaxValuedouble100Maximum value of the range
Stepdouble1Step increment for arrow keys
LargeStepdouble10Large step for Page Up/Down and Shift+Arrow
OrientationSliderOrientationHorizontalSlider orientation
ShowValueLabelboolfalseShow current value label
ShowMinMaxLabelsboolfalseShow min/max labels at track ends
ValueLabelFormatstring"F0"Format string for value labels
TrackColorColor?ThemeUnfilled track color
FilledTrackColorColor?ThemeFilled track color
ThumbColorColor?ThemeThumb indicator color
FocusedThumbColorColor?ThemeThumb color when focused
BackgroundColorColor?InheritedBackground color
IsEnabledbooltrueWhether the slider accepts input

Events

EventTypeDescription
ValueChangedEventHandler<double>Fires when the value changes
GotFocusEventHandlerFires when the slider receives focus
LostFocusEventHandlerFires when the slider loses focus

Creating with Builder

// Basic slider
var slider = Controls.Slider()
    .WithValue(50)
    .ShowValueLabel()
    .Build();

// Slider with range and step
var brightness = Controls.Slider()
    .WithRange(0, 100)
    .WithStep(5)
    .ShowMinMaxLabels()
    .OnValueChanged((s, v) => label.SetLines($"Brightness: {v}"))
    .Build();

// Vertical slider
var volume = Controls.Slider()
    .Vertical()
    .WithRange(0, 100)
    .ShowValueLabel()
    .Build();

// Custom colors
var custom = Controls.Slider()
    .WithTrackColor(Color.Green)
    .WithFilledTrackColor(Color.Red)
    .WithThumbColor(Color.Magenta1)
    .Build();

Keyboard Shortcuts

Horizontal Mode

KeyAction
Right ArrowIncrease by Step
Left ArrowDecrease by Step
Shift+RightIncrease by LargeStep
Shift+LeftDecrease by LargeStep
Page UpIncrease by LargeStep
Page DownDecrease by LargeStep
HomeSet to MinValue
EndSet to MaxValue

Vertical Mode

KeyAction
Up ArrowIncrease by Step
Down ArrowDecrease by Step
Shift+UpIncrease by LargeStep
Shift+DownDecrease by LargeStep

Mouse Interaction

  • Click on thumb: Start dragging
  • Click on track: Jump to clicked position, then start dragging
  • Drag: Continuously update value based on mouse movement

Visual Layout

Horizontal

[0] │━━━━━●───────│ [100]  50
    ^cap  ^thumb   ^cap     ^value label

Vertical

100   ← max label
 ─    ← top end-cap
 │    ← unfilled
 ●    ← thumb (value label appears next to it)
 ┃    ← filled
 ─    ← bottom end-cap
 0    ← min label