Skip to main content

Style Color Stack

PushStyleColor

Modify a style color. Always use this if you modify the style after NewFrame().
ImGuiCol
Color identifier (e.g., ImGuiCol_WindowBg, ImGuiCol_Button)
ImU32 or ImVec4
Color value
Example:

PopStyleColor

Restore previous style color(s).
int
default:"1"
Number of colors to pop
Always match PushStyleColor() with PopStyleColor(). Mismatched push/pop will cause issues.
Example:

Color Retrieval

GetColorU32

Retrieve color with style alpha applied, packed as a 32-bit value suitable for ImDrawList.
ImGuiCol
Style color identifier
ImVec4 or ImU32
Color value
float
default:"1.0f"
Optional extra alpha multiplier
ImU32
32-bit color value with alpha applied
Example:

GetStyleColorVec4

Retrieve style color as stored in ImGuiStyle structure. Use to feed back into PushStyleColor().
ImGuiCol
Color identifier
const ImVec4&
Color as ImVec4
Use GetColorU32() instead if you need the color for drawing, as it applies style alpha.

ImGuiCol Enum

Color identifiers for styling:

Color Utilities

ColorConvertU32ToFloat4

Convert 32-bit packed color to ImVec4.
ImU32
32-bit packed color (RGBA)
ImVec4
Color as ImVec4 with components in range [0.0f, 1.0f]

ColorConvertFloat4ToU32

Convert ImVec4 color to 32-bit packed color.
const ImVec4&
Color as ImVec4
ImU32
32-bit packed color (RGBA)
Example:

ColorConvertRGBtoHSV

Convert RGB color to HSV.
float
RGB components in range [0.0f, 1.0f]
float&
Output HSV components. H in range [0.0f, 1.0f], S and V in range [0.0f, 1.0f]

ColorConvertHSVtoRGB

Convert HSV color to RGB.
float
HSV components. H in range [0.0f, 1.0f], S and V in range [0.0f, 1.0f]
float&
Output RGB components in range [0.0f, 1.0f]
Example:

Color Macros

IM_COL32

Create a 32-bit packed color from RGBA components (0-255). Example:

IM_COL32_WHITE / IM_COL32_BLACK

Pre-defined color constants.

ImColor Helper

ImColor is obsolete. Please avoid using it. Just use ImVec4 or ImU32 directly.

Common Color Patterns

Themed Button

Danger Button

Transparent Window

Highlighted Section

Modifying Default Colors

See Also