Skip to main content
Input widgets allow users to enter and edit data. Dear ImGui provides input functions for text, integers, floats, and other data types.

Text Input

InputText()

Single-line text input:
const char*
required
Widget label
char*
required
Character buffer to edit
size_t
required
Size of the buffer (including null terminator)
ImGuiInputTextFlags
default:"0"
Optional input text flags (see below)

InputTextMultiline()

Multi-line text input:

InputTextWithHint()

Text input with placeholder hint:

Input Text Flags

Customize text input behavior with flags:
Common flags include:
  • ImGuiInputTextFlags_EnterReturnsTrue - Return true when Enter pressed
  • ImGuiInputTextFlags_Password - Display as password (***)
  • ImGuiInputTextFlags_ReadOnly - Read-only mode
  • ImGuiInputTextFlags_CharsDecimal - Allow 0-9 . + - *
  • ImGuiInputTextFlags_CharsNoBlank - Filter out spaces and tabs

Numeric Input

InputInt()

Integer input with optional step buttons:

InputFloat()

Floating-point input:

InputDouble()

Double-precision input:

Multi-Component Input

InputFloat2/3/4()

Input multiple float values:

InputInt2/3/4()

Input multiple integer values:

Generic Scalar Input

InputScalar()

Input any scalar data type:
ImGuiDataType
required
Data type:
  • ImGuiDataType_S8, ImGuiDataType_U8
  • ImGuiDataType_S16, ImGuiDataType_U16
  • ImGuiDataType_S32, ImGuiDataType_U32
  • ImGuiDataType_S64, ImGuiDataType_U64
  • ImGuiDataType_Float, ImGuiDataType_Double

Input Validation and Callbacks

Use callbacks to validate or process input:

Complete Example

Best Practices

Use ImGuiInputTextFlags_EnterReturnsTrue to detect when the user presses Enter to confirm input.
Always provide a buffer large enough for your expected input plus the null terminator.
Check IsItemDeactivatedAfterEdit() after an input widget to detect when editing is complete and the value has changed.