Skip to main content

Button Functions

Most widgets return true when the value has been changed or when pressed/selected.

Button

Standard button widget.
const char*
Button label text
const ImVec2&
default:"ImVec2(0, 0)"
Button size. Use 0 for auto-sizing
bool
True when clicked

SmallButton

Button with FramePadding.y == 0 to easily embed within text.
const char*
Button label text
bool
True when clicked

InvisibleButton

Flexible button behavior without the visuals. Frequently useful to build custom behaviors using the public API (along with IsItemActive, IsItemHovered, etc.).
const char*
Unique identifier (not displayed)
const ImVec2&
Button size
ImGuiButtonFlags
default:"0"
Button flags (see ImGuiButtonFlags_)
bool
True when clicked

ArrowButton

Square button with an arrow shape.
const char*
Unique identifier
ImGuiDir
Arrow direction: ImGuiDir_Left, ImGuiDir_Right, ImGuiDir_Up, ImGuiDir_Down
bool
True when clicked

Checkbox & Radio

Checkbox

Checkbox widget.
const char*
Checkbox label
bool*
Pointer to boolean value
bool
True when the value changes

CheckboxFlags (int)

Checkbox for bitflags (int).
const char*
Checkbox label
int*
Pointer to flags variable
int
Flag bit to toggle
bool
True when the value changes

CheckboxFlags (unsigned int)

Checkbox for bitflags (unsigned int).
const char*
Checkbox label
unsigned int*
Pointer to flags variable
unsigned int
Flag bit to toggle
bool
True when the value changes

RadioButton (bool)

Use with e.g. if (RadioButton("one", my_value==1)) { my_value = 1; }
const char*
Radio button label
bool
Whether this option is currently selected
bool
True when clicked

RadioButton (int)

Shortcut to handle the radio button pattern when value is an integer.
const char*
Radio button label
int*
Pointer to current value
int
Value for this button
bool
True when the value changes

Other Widgets

ProgressBar

Display a progress bar.
float
Progress value (0.0f to 1.0f)
const ImVec2&
default:"ImVec2(-FLT_MIN, 0)"
Size of the progress bar
const char*
default:"NULL"
Optional text overlay
Hyperlink text button, return true when clicked.
const char*
Link text
bool
True when clicked

TextLinkOpenURL

Hyperlink text button, automatically open file/url when clicked.
const char*
Link text
const char*
default:"NULL"
URL to open (uses label if NULL)
bool
True when clicked

Button Flags

ImGuiButtonFlags_

Flags for InvisibleButton().