Skip to main content

Text Input

InputText

bool ImGui::InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL)
Single-line text input.
label
const char*
Widget label
buf
char*
Text buffer
buf_size
size_t
Buffer size including null terminator
flags
ImGuiInputTextFlags
default:"0"
Input flags (see ImGuiInputTextFlags_)
callback
ImGuiInputTextCallback
default:"NULL"
Optional callback function
user_data
void*
default:"NULL"
Optional user data passed to callback
return
bool
True when value has been modified
// Example
static char text[128] = "Hello";
ImGui::InputText("Label", text, IM_COUNTOF(text));

InputTextMultiline

bool ImGui::InputTextMultiline(const char* label, char* buf, size_t buf_size, const ImVec2& size = ImVec2(0, 0), ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL)
Multi-line text input.
label
const char*
Widget label
buf
char*
Text buffer
buf_size
size_t
Buffer size including null terminator
size
const ImVec2&
default:"ImVec2(0, 0)"
Size of the input area
flags
ImGuiInputTextFlags
default:"0"
Input flags
callback
ImGuiInputTextCallback
default:"NULL"
Optional callback function
user_data
void*
default:"NULL"
Optional user data
return
bool
True when value has been modified
// Example
static char text[1024] = "Multi-line\ntext";
ImGui::InputTextMultiline("##source", text, IM_COUNTOF(text), ImVec2(-FLT_MIN, ImGui::GetTextLineHeight() * 16));

InputTextWithHint

bool ImGui::InputTextWithHint(const char* label, const char* hint, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL)
Input with a hint/placeholder text.
label
const char*
Widget label
hint
const char*
Hint text displayed when empty
buf
char*
Text buffer
buf_size
size_t
Buffer size
flags
ImGuiInputTextFlags
default:"0"
Input flags
return
bool
True when value has been modified
// Example
static char str[128] = "";
ImGui::InputTextWithHint("Search", "Enter search term...", str, IM_COUNTOF(str));

Numeric Input

InputFloat

bool ImGui::InputFloat(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, const char* format = "%.3f", ImGuiInputTextFlags flags = 0)
Input a float value.
label
const char*
Widget label
v
float*
Pointer to float value
step
float
default:"0.0f"
Step size for +/- buttons
step_fast
float
default:"0.0f"
Fast step size (when holding Shift)
format
const char*
default:"%.3f"
Display format
flags
ImGuiInputTextFlags
default:"0"
Input flags
return
bool
True when value has been modified
// Example
static float f = 0.001f;
ImGui::InputFloat("Float", &f, 0.01f, 1.0f, "%.3f");

InputFloat2

bool ImGui::InputFloat2(const char* label, float v[2], const char* format = "%.3f", ImGuiInputTextFlags flags = 0)
Input 2 float values.
label
const char*
Widget label
v
float[2]
Array of 2 floats
format
const char*
default:"%.3f"
Display format
flags
ImGuiInputTextFlags
default:"0"
Input flags
return
bool
True when value has been modified
// Example
static float vec2[2] = { 0.0f, 0.0f };
ImGui::InputFloat2("Position", vec2);

InputFloat3

bool ImGui::InputFloat3(const char* label, float v[3], const char* format = "%.3f", ImGuiInputTextFlags flags = 0)
Input 3 float values.
label
const char*
Widget label
v
float[3]
Array of 3 floats
format
const char*
default:"%.3f"
Display format
flags
ImGuiInputTextFlags
default:"0"
Input flags
return
bool
True when value has been modified
// Example
static float vec3[3] = { 0.0f, 0.0f, 0.0f };
ImGui::InputFloat3("Position", vec3);

InputFloat4

bool ImGui::InputFloat4(const char* label, float v[4], const char* format = "%.3f", ImGuiInputTextFlags flags = 0)
Input 4 float values.
label
const char*
Widget label
v
float[4]
Array of 4 floats
format
const char*
default:"%.3f"
Display format
flags
ImGuiInputTextFlags
default:"0"
Input flags
return
bool
True when value has been modified

InputInt

bool ImGui::InputInt(const char* label, int* v, int step = 1, int step_fast = 100, ImGuiInputTextFlags flags = 0)
Input an integer value.
label
const char*
Widget label
v
int*
Pointer to int value
step
int
default:"1"
Step size for +/- buttons
step_fast
int
default:"100"
Fast step size (when holding Shift)
flags
ImGuiInputTextFlags
default:"0"
Input flags
return
bool
True when value has been modified
// Example
static int i = 0;
ImGui::InputInt("Integer", &i);

InputInt2

bool ImGui::InputInt2(const char* label, int v[2], ImGuiInputTextFlags flags = 0)
Input 2 integer values.

InputInt3

bool ImGui::InputInt3(const char* label, int v[3], ImGuiInputTextFlags flags = 0)
Input 3 integer values.

InputInt4

bool ImGui::InputInt4(const char* label, int v[4], ImGuiInputTextFlags flags = 0)
Input 4 integer values.

InputDouble

bool ImGui::InputDouble(const char* label, double* v, double step = 0.0, double step_fast = 0.0, const char* format = "%.6f", ImGuiInputTextFlags flags = 0)
Input a double value.
label
const char*
Widget label
v
double*
Pointer to double value
step
double
default:"0.0"
Step size for +/- buttons
step_fast
double
default:"0.0"
Fast step size
format
const char*
default:"%.6f"
Display format
flags
ImGuiInputTextFlags
default:"0"
Input flags
return
bool
True when value has been modified

Input Text Flags

ImGuiInputTextFlags_

Flags for InputText(), InputTextMultiline() functions.

Basic Filters

FlagDescription
ImGuiInputTextFlags_CharsDecimalAllow 0123456789.+-*/
ImGuiInputTextFlags_CharsHexadecimalAllow 0123456789ABCDEFabcdef
ImGuiInputTextFlags_CharsScientificAllow 0123456789.+-*/eE
ImGuiInputTextFlags_CharsUppercaseTurn a..z into A..Z
ImGuiInputTextFlags_CharsNoBlankFilter out spaces, tabs

Input Behavior

FlagDescription
ImGuiInputTextFlags_AllowTabInputPressing TAB inputs a ‘\t’ character
ImGuiInputTextFlags_EnterReturnsTrueReturn true when Enter is pressed
ImGuiInputTextFlags_EscapeClearsAllEscape key clears content
ImGuiInputTextFlags_CtrlEnterForNewLineIn multi-line mode: validate with Enter, add new line with Ctrl+Enter

Options

FlagDescription
ImGuiInputTextFlags_ReadOnlyRead-only mode
ImGuiInputTextFlags_PasswordDisplay all characters as ’*‘
ImGuiInputTextFlags_AlwaysOverwriteOverwrite mode
ImGuiInputTextFlags_AutoSelectAllSelect entire text when first taking focus
ImGuiInputTextFlags_NoHorizontalScrollDisable following cursor horizontally
ImGuiInputTextFlags_NoUndoRedoDisable undo/redo
ImGuiInputTextFlags_ElideLeftElide left side when text doesn’t fit

Callbacks

FlagDescription
ImGuiInputTextFlags_CallbackCompletionCallback on pressing TAB
ImGuiInputTextFlags_CallbackHistoryCallback on pressing Up/Down arrows
ImGuiInputTextFlags_CallbackAlwaysCallback on each iteration
ImGuiInputTextFlags_CallbackCharFilterCallback on character inputs
ImGuiInputTextFlags_CallbackResizeCallback on buffer capacity changes
ImGuiInputTextFlags_CallbackEditCallback on any edit

Build docs developers (and LLMs) love