Overview
ImGuiStyle contains all the style configuration for Dear ImGui, including colors, sizes, padding, rounding, and spacing. You can modify the style during initialization or between frames.
During the frame, use PushStyleColor()/PopStyleColor() and PushStyleVar()/PopStyleVar() to temporarily modify style values.
Getting Style
GetStyle
Access the Style structure.
Reference to the current style
Example:
ImGuiStyle& style = ImGui::GetStyle();
style.WindowRounding = 0.0f;
style.Colors[ImGuiCol_WindowBg] = ImVec4(0.1f, 0.1f, 0.1f, 1.0f);
Style Presets
StyleColorsDark
void StyleColorsDark(ImGuiStyle* dst = NULL);
New, recommended dark style (default).
StyleColorsLight
void StyleColorsLight(ImGuiStyle* dst = NULL);
Light style, best used with borders and a custom thicker font.
StyleColorsClassic
void StyleColorsClassic(ImGuiStyle* dst = NULL);
Classic Dear ImGui style.
Example:
ImGui::StyleColorsDark();
// or
ImGui::StyleColorsLight();
ImGuiStyle Structure
struct ImGuiStyle
{
// Font scaling
float FontSizeBase; // Base font size
float FontScaleMain; // Main global scale factor
float FontScaleDpi; // DPI scale factor
// Main
float Alpha; // Global alpha
float DisabledAlpha; // Additional alpha for disabled items
// Window
ImVec2 WindowPadding; // Padding within a window
float WindowRounding; // Window corner rounding
float WindowBorderSize; // Window border thickness
ImVec2 WindowMinSize; // Minimum window size
ImVec2 WindowTitleAlign; // Title bar text alignment
ImGuiDir WindowMenuButtonPosition; // Side of collapse button
// Child windows
float ChildRounding; // Child window corner rounding
float ChildBorderSize; // Child window border thickness
// Popups
float PopupRounding; // Popup corner rounding
float PopupBorderSize; // Popup border thickness
// Frames
ImVec2 FramePadding; // Padding within framed rectangle
float FrameRounding; // Frame corner rounding
float FrameBorderSize; // Frame border thickness
// Spacing
ImVec2 ItemSpacing; // Horizontal and vertical spacing
ImVec2 ItemInnerSpacing; // Spacing within elements
ImVec2 CellPadding; // Table cell padding
float IndentSpacing; // Horizontal indentation
// Scrollbars
float ScrollbarSize; // Width of scrollbar
float ScrollbarRounding; // Scrollbar grab corner rounding
float ScrollbarPadding; // Padding of scrollbar grab
float GrabMinSize; // Minimum grab box size
float GrabRounding; // Grab corner rounding
// Images
float ImageRounding; // Image corner rounding
float ImageBorderSize; // Image border thickness
// Tabs
float TabRounding; // Tab corner rounding
float TabBorderSize; // Tab border thickness
float TabBarBorderSize; // Tab bar separator thickness
float TabBarOverlineSize; // Tab bar overline thickness
// Misc
float LogSliderDeadzone; // Dead-zone for log sliders
float ColorMarkerSize; // Size of R/G/B/A color markers
float SeparatorSize; // Separator thickness
// Alignment
ImVec2 ButtonTextAlign; // Button text alignment
ImVec2 SelectableTextAlign; // Selectable text alignment
ImVec2 SeparatorTextAlign; // Separator text alignment
// Colors
ImVec4 Colors[ImGuiCol_COUNT]; // All color values
// Behaviors
float HoverStationaryDelay; // Delay for stationary hover
float HoverDelayShort; // Short hover delay
float HoverDelayNormal; // Normal hover delay
// ... more fields ...
};
Common Style Fields
Padding and Spacing
Padding within a framed rectangle (used by most widgets).
Horizontal and vertical spacing between widgets/lines.
Horizontal and vertical spacing between within elements of a composed widget.
Horizontal indentation when entering a tree node. Generally equals (FontSize + FramePadding.x*2).
Example:
ImGuiStyle& style = ImGui::GetStyle();
style.WindowPadding = ImVec2(15, 15);
style.FramePadding = ImVec2(5, 5);
style.ItemSpacing = ImVec2(12, 8);
Rounding
Radius of window corners. Set to 0.0f for rectangular windows.
Radius of scrollbar grab corners.
Radius of grab corners for sliders.
Radius of upper tab corners.
Example:
style.WindowRounding = 5.0f;
style.FrameRounding = 3.0f;
style.GrabRounding = 3.0f;
Border Sizes
Thickness of border around windows. Generally set to 0.0f or 1.0f.
Thickness of border around frames. Generally set to 0.0f or 1.0f.
Thickness of border around popups/tooltips.
Anti-Aliasing
Enable anti-aliased lines/borders. Disable if you are really tight on CPU/GPU.
Enable anti-aliased lines/borders using textures where possible. Requires backend to render with bilinear filtering.
Enable anti-aliased edges around filled shapes (rounded rectangles, circles).
Example:
style.AntiAliasedLines = true;
style.AntiAliasedLinesUseTex = true;
style.AntiAliasedFill = true;
Scaling
ScaleAllSizes
void ImGuiStyle::ScaleAllSizes(float scale_factor);
Scale all spacing/padding/thickness values. Does not scale fonts.
Example:
ImGuiStyle& style = ImGui::GetStyle();
style.ScaleAllSizes(1.5f); // Make everything 50% larger
For DPI scaling, also consider adjusting font size.
Style Editor
ShowStyleEditor
void ShowStyleEditor(ImGuiStyle* ref = NULL);
Add style editor block (not a window). You can pass in a reference ImGuiStyle structure to compare to, revert to and save to.
ref
ImGuiStyle*
default:"NULL"
Reference style for comparison
Example:
ImGui::Begin("Style Editor");
ImGui::ShowStyleEditor();
ImGui::End();
ShowStyleSelector
bool ShowStyleSelector(const char* label);
Add style selector block (not a window), essentially a combo listing the default styles.
True if style was changed
Example:
ImGui::ShowStyleSelector("Style");
Temporary Style Changes
See Colors for PushStyleColor()/PopStyleColor() and style variable functions.
Common Style Customizations
Flat Style
ImGuiStyle& style = ImGui::GetStyle();
style.WindowRounding = 0.0f;
style.ChildRounding = 0.0f;
style.FrameRounding = 0.0f;
style.GrabRounding = 0.0f;
style.PopupRounding = 0.0f;
style.ScrollbarRounding = 0.0f;
style.TabRounding = 0.0f;
Rounded Style
style.WindowRounding = 6.0f;
style.ChildRounding = 6.0f;
style.FrameRounding = 4.0f;
style.GrabRounding = 4.0f;
style.PopupRounding = 4.0f;
style.ScrollbarRounding = 9.0f;
style.TabRounding = 4.0f;
Compact Style
style.WindowPadding = ImVec2(4, 4);
style.FramePadding = ImVec2(4, 2);
style.ItemSpacing = ImVec2(4, 4);
style.ItemInnerSpacing = ImVec2(4, 4);
style.IndentSpacing = 12.0f;
Spacious Style
style.WindowPadding = ImVec2(15, 15);
style.FramePadding = ImVec2(8, 6);
style.ItemSpacing = ImVec2(12, 8);
style.ItemInnerSpacing = ImVec2(8, 6);
style.IndentSpacing = 25.0f;
See Also
- Colors - Color configuration and style colors
- Fonts - Font configuration
- ImGuiStyle - Complete style structure reference