Skip to main content

Text Functions

Functions for displaying text in various styles and formats.

Text

void ImGui::Text(const char* fmt, ...)
Display formatted text.
fmt
const char*
Format string (printf-style)
// Example
ImGui::Text("Hello, World!");
ImGui::Text("FPS: %.1f", fps);

TextUnformatted

void ImGui::TextUnformatted(const char* text, const char* text_end = NULL)
Raw text without formatting. Roughly equivalent to Text("%s", text) but faster with no memory copy, no buffer size limits.
text
const char*
Text to display
text_end
const char*
default:"NULL"
Optional end pointer. If specified, doesn’t require null-terminated string
// Example
const char* large_text = "...";
ImGui::TextUnformatted(large_text);

TextColored

void ImGui::TextColored(const ImVec4& col, const char* fmt, ...)
Shortcut for PushStyleColor(ImGuiCol_Text, col); Text(fmt, ...); PopStyleColor();
col
const ImVec4&
RGBA color (0.0f to 1.0f per component)
fmt
const char*
Format string (printf-style)
// Example
ImGui::TextColored(ImVec4(1.0f, 0.0f, 0.0f, 1.0f), "Error!");
ImGui::TextColored(ImVec4(0.0f, 1.0f, 0.0f, 1.0f), "Success!");

TextDisabled

void ImGui::TextDisabled(const char* fmt, ...)
Shortcut for PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]); Text(fmt, ...); PopStyleColor();
fmt
const char*
Format string (printf-style)
// Example
ImGui::TextDisabled("(disabled)");

TextWrapped

void ImGui::TextWrapped(const char* fmt, ...)
Shortcut for PushTextWrapPos(0.0f); Text(fmt, ...); PopTextWrapPos();. Note that this won’t work on an auto-resizing window if there’s no other widgets to extend the window width.
fmt
const char*
Format string (printf-style)
// Example
ImGui::TextWrapped("This is a long text that will wrap to the next line when it reaches the edge of the window.");

LabelText

void ImGui::LabelText(const char* label, const char* fmt, ...)
Display text+label aligned the same way as value+label widgets.
label
const char*
Label text displayed on the left
fmt
const char*
Format string for the value (printf-style)
// Example
ImGui::LabelText("Position", "X: %.2f, Y: %.2f", x, y);

BulletText

void ImGui::BulletText(const char* fmt, ...)
Shortcut for Bullet() + Text().
fmt
const char*
Format string (printf-style)
// Example
ImGui::BulletText("Item 1");
ImGui::BulletText("Item 2");
ImGui::BulletText("Item 3");

SeparatorText

void ImGui::SeparatorText(const char* label)
Currently: formatted text with a horizontal line.
label
const char*
Text to display in the separator
// Example
ImGui::SeparatorText("Settings");

Helper Functions

Bullet

void ImGui::Bullet()
Draw a small circle and keep the cursor on the same line. Advance cursor x position by GetTreeNodeToLabelSpacing(), same distance that TreeNode() uses.
// Example
ImGui::Bullet(); ImGui::Text("Manual bullet point");

CalcTextSize

ImVec2 ImGui::CalcTextSize(const char* text, const char* text_end = NULL, bool hide_text_after_double_hash = false, float wrap_width = -1.0f)
Calculate text size. Returns size in pixels.
text
const char*
Text to measure
text_end
const char*
default:"NULL"
Optional end pointer
hide_text_after_double_hash
bool
default:"false"
Hide text after ##
wrap_width
float
default:"-1.0f"
Wrap width (-1.0f = no wrapping)
return
ImVec2
Size of the text in pixels
// Example
ImVec2 size = ImGui::CalcTextSize("Hello");
ImGui::Text("Text size: %.0f x %.0f", size.x, size.y);

Build docs developers (and LLMs) love