Skip to main content

Slider Widgets

Ctrl+Click on any slider to turn them into an input box. Manually input values aren’t clamped by default and can go off-bounds. Use ImGuiSliderFlags_AlwaysClamp to always clamp.

SliderFloat

bool ImGui::SliderFloat(const char* label, float* v, float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0)
Float slider widget.
label
const char*
Widget label
v
float*
Pointer to float value
v_min
float
Minimum value
v_max
float
Maximum value
format
const char*
default:"%.3f"
Display format string
flags
ImGuiSliderFlags
default:"0"
Slider flags (see ImGuiSliderFlags_)
return
bool
True when value has been modified
// Example
static float f = 0.5f;
ImGui::SliderFloat("Float", &f, 0.0f, 1.0f);

SliderFloat2

bool ImGui::SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0)
Slider for 2 float values.

SliderFloat3

bool ImGui::SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0)
Slider for 3 float values.

SliderFloat4

bool ImGui::SliderFloat4(const char* label, float v[4], float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0)
Slider for 4 float values.

SliderInt

bool ImGui::SliderInt(const char* label, int* v, int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0)
Integer slider widget.
label
const char*
Widget label
v
int*
Pointer to int value
v_min
int
Minimum value
v_max
int
Maximum value
format
const char*
default:"%d"
Display format string
flags
ImGuiSliderFlags
default:"0"
Slider flags
return
bool
True when value has been modified
// Example
static int i = 50;
ImGui::SliderInt("Integer", &i, 0, 100);

SliderInt2

bool ImGui::SliderInt2(const char* label, int v[2], int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0)
Slider for 2 int values.

SliderInt3

bool ImGui::SliderInt3(const char* label, int v[3], int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0)
Slider for 3 int values.

SliderInt4

bool ImGui::SliderInt4(const char* label, int v[4], int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0)
Slider for 4 int values.

SliderAngle

bool ImGui::SliderAngle(const char* label, float* v_rad, float v_degrees_min = -360.0f, float v_degrees_max = +360.0f, const char* format = "%.0f deg", ImGuiSliderFlags flags = 0)
Slider for angles (in radians).
label
const char*
Widget label
v_rad
float*
Pointer to angle value in radians
v_degrees_min
float
default:"-360.0f"
Minimum angle in degrees
v_degrees_max
float
default:"+360.0f"
Maximum angle in degrees
format
const char*
default:"%.0f deg"
Display format
flags
ImGuiSliderFlags
default:"0"
Slider flags
return
bool
True when value has been modified

VSliderFloat

bool ImGui::VSliderFloat(const char* label, const ImVec2& size, float* v, float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0)
Vertical slider for float values.
label
const char*
Widget label
size
const ImVec2&
Slider size
v
float*
Pointer to float value
v_min
float
Minimum value
v_max
float
Maximum value
format
const char*
default:"%.3f"
Display format
flags
ImGuiSliderFlags
default:"0"
Slider flags
return
bool
True when value has been modified

VSliderInt

bool ImGui::VSliderInt(const char* label, const ImVec2& size, int* v, int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0)
Vertical slider for int values.

Drag Widgets

Ctrl+Click on any drag box to turn them into an input box. Use ImGuiSliderFlags_AlwaysClamp to always clamp. Speed is per-pixel of mouse movement (v_speed=0.2f: mouse needs to move by 5 pixels to increase value by 1).

DragFloat

bool ImGui::DragFloat(const char* label, float* v, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0)
Drag to input float. If v_min >= v_max we have no bound.
label
const char*
Widget label
v
float*
Pointer to float value
v_speed
float
default:"1.0f"
Speed of value change per pixel of mouse movement
v_min
float
default:"0.0f"
Minimum value (no bound if v_min >= v_max)
v_max
float
default:"0.0f"
Maximum value
format
const char*
default:"%.3f"
Display format
flags
ImGuiSliderFlags
default:"0"
Slider flags
return
bool
True when value has been modified
// Example
static float f = 0.0f;
ImGui::DragFloat("Float", &f, 0.01f);

// With bounds
ImGui::DragFloat("Clamped", &f, 0.01f, 0.0f, 1.0f);

DragFloat2

bool ImGui::DragFloat2(const char* label, float v[2], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0)
Drag to input 2 float values.

DragFloat3

bool ImGui::DragFloat3(const char* label, float v[3], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0)
Drag to input 3 float values.

DragFloat4

bool ImGui::DragFloat4(const char* label, float v[4], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0)
Drag to input 4 float values.

DragFloatRange2

bool ImGui::DragFloatRange2(const char* label, float* v_current_min, float* v_current_max, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", const char* format_max = NULL, ImGuiSliderFlags flags = 0)
Drag to input a range of float values.
label
const char*
Widget label
v_current_min
float*
Pointer to current minimum value
v_current_max
float*
Pointer to current maximum value
v_speed
float
default:"1.0f"
Speed of value change
v_min
float
default:"0.0f"
Absolute minimum value
v_max
float
default:"0.0f"
Absolute maximum value
format
const char*
default:"%.3f"
Display format for min value
format_max
const char*
default:"NULL"
Display format for max value (uses format if NULL)
flags
ImGuiSliderFlags
default:"0"
Slider flags
return
bool
True when value has been modified

DragInt

bool ImGui::DragInt(const char* label, int* v, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", ImGuiSliderFlags flags = 0)
Drag to input int. If v_min >= v_max we have no bound.
label
const char*
Widget label
v
int*
Pointer to int value
v_speed
float
default:"1.0f"
Speed of value change
v_min
int
default:"0"
Minimum value
v_max
int
default:"0"
Maximum value
format
const char*
default:"%d"
Display format
flags
ImGuiSliderFlags
default:"0"
Slider flags
return
bool
True when value has been modified
// Example
static int i = 0;
ImGui::DragInt("Integer", &i, 1, 0, 100);

DragInt2

bool ImGui::DragInt2(const char* label, int v[2], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", ImGuiSliderFlags flags = 0)
Drag to input 2 int values.

DragInt3

bool ImGui::DragInt3(const char* label, int v[3], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", ImGuiSliderFlags flags = 0)
Drag to input 3 int values.

DragInt4

bool ImGui::DragInt4(const char* label, int v[4], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", ImGuiSliderFlags flags = 0)
Drag to input 4 int values.

DragIntRange2

bool ImGui::DragIntRange2(const char* label, int* v_current_min, int* v_current_max, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", const char* format_max = NULL, ImGuiSliderFlags flags = 0)
Drag to input a range of int values.

Slider Flags

ImGuiSliderFlags_

Flags for DragFloat(), DragInt(), SliderFloat(), SliderInt() etc.
FlagDescription
ImGuiSliderFlags_NoneDefault
ImGuiSliderFlags_LogarithmicMake the widget logarithmic (linear otherwise)
ImGuiSliderFlags_NoRoundToFormatDisable rounding underlying value to match precision of the display format
ImGuiSliderFlags_NoInputDisable Ctrl+Click or Enter key allowing to input text directly
ImGuiSliderFlags_WrapAroundEnable wrapping around from max to min and from min to max (DragXXX only)
ImGuiSliderFlags_ClampOnInputClamp value to min/max bounds when input manually with Ctrl+Click
ImGuiSliderFlags_ClampZeroRangeClamp even if min==max==0.0f
ImGuiSliderFlags_AlwaysClampClampOnInput + ClampZeroRange
ImGuiSliderFlags_NoSpeedTweaksDisable keyboard modifiers altering tweak speed
ImGuiSliderFlags_ColorMarkersDraw R/G/B/A color markers on each component
// Example
static float f = 1.0f;
ImGui::SliderFloat("Clamped", &f, 0.0f, 1.0f, "%.3f", ImGuiSliderFlags_AlwaysClamp);

static float log_val = 1.0f;
ImGui::SliderFloat("Logarithmic", &log_val, 0.001f, 1000.0f, "%.3f", ImGuiSliderFlags_Logarithmic);

Build docs developers (and LLMs) love