Skip to main content
Buttons are fundamental interactive widgets that respond to user clicks. Dear ImGui provides several button types for different use cases.

Standard Button

Button()

Create a clickable button that returns true when pressed:
const char*
required
The text displayed on the button
ImVec2
default:"ImVec2(0, 0)"
Button size in pixels. Use (0,0) for auto-sizing to fit the label.

Button Variants

SmallButton()

A button with reduced padding, useful for embedding in text:

InvisibleButton()

A button without visual decoration, useful for custom rendering:
const char*
required
String identifier (not displayed)
ImVec2
required
Button size in pixels
ImGuiButtonFlags
Optional button flags:
  • ImGuiButtonFlags_MouseButtonLeft (default)
  • ImGuiButtonFlags_MouseButtonRight
  • ImGuiButtonFlags_MouseButtonMiddle

ArrowButton()

A button displaying a directional arrow:
ImGuiDir
required
Arrow direction:
  • ImGuiDir_Left
  • ImGuiDir_Right
  • ImGuiDir_Up
  • ImGuiDir_Down

Button Modifiers

Repeating Buttons

Make buttons fire continuously while held down:
With ImGuiItemFlags_ButtonRepeat enabled, the button returns true multiple times while held, not just on initial press.

Colored Buttons

Customize button colors using style modifiers:

Checkbox and Radio Buttons

Checkbox()

Toggle boolean values:

RadioButton()

Select one option from a group:

Image Buttons

ImageButton()

Create a button with an image:
const char*
required
String identifier for the button
ImTextureRef
required
Texture reference (your texture ID cast to ImTextureRef)
ImVec2
required
Size of the image to display
ImVec2
default:"(0,0), (1,1)"
UV coordinates for the image texture

Button with Tooltip

Add tooltips to buttons for additional information:

Complete Example

Best Practices

Use PushID() / PopID() or the ## label syntax when you need multiple buttons with the same label.
Button size (0,0) means auto-size. Use (-FLT_MIN, 0) for full-width buttons.