Skip to main content
Sliders and drag widgets provide visual feedback for adjusting numeric values. They’re essential for parameters that need to be tweaked interactively.

Slider Widgets

SliderFloat()

Adjust a float value within a range:
const char*
required
Widget label
float*
required
Pointer to the value to modify
float
required
Minimum and maximum values
const char*
default:"%.3f"
Display format string (printf-style)

SliderInt()

Adjust an integer value:

SliderAngle()

Slider specialized for angles:

Multi-Component Sliders

SliderFloat2/3/4()

Slide multiple float values:

SliderInt2/3/4()

Slide multiple integer values:

Vertical Sliders

VSliderFloat() / VSliderInt()

Vertical slider widgets:

Drag Widgets

DragFloat()

Drag to adjust a float value:
float
default:"1.0f"
Speed of value change per pixel of mouse movement
float
Optional range limits. Use v_min >= v_max for no bounds.
Drag widgets are useful when you need:
  • Fine control over the value
  • No strict visual bounds
  • Keyboard/gamepad navigation with custom speed

DragInt()

Drag to adjust an integer value:

Range Widgets

DragFloatRange2()

Drag a range with min/max values:

DragIntRange2()

Slider and Drag Flags

Customize behavior with flags:

Ctrl+Click to Input

By default, users can Ctrl+Click on sliders/drags to input values directly:
Hold Shift or Alt while dragging to adjust speed on the fly (slower or faster).

Generic Scalar Widgets

DragScalar() / SliderScalar()

Work with any data type:

Complete Example

Best Practices

Use ImGuiSliderFlags_AlwaysClamp to prevent users from entering out-of-range values via Ctrl+Click.
For DragXXX widgets, set v_min >= v_max to indicate no clamping bounds.
The v_speed parameter in DragXXX is per-pixel of mouse movement. Start with small values like 0.005f for floats.