Skip to content

Flag for centered tab bars? #8654

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
aardappel opened this issue May 23, 2025 · 1 comment
Open

Flag for centered tab bars? #8654

aardappel opened this issue May 23, 2025 · 1 comment
Labels
style tabs tab bars, tabs

Comments

@aardappel
Copy link

Version/Branch of Dear ImGui:

v1.91.3 docking

Back-ends:

SDL + opengl 3

Compiler, OS:

VS 2022

Full config/build information:

No response

Details:

Would a flag for centered tab bars be a good idea?

I am aware that centering UI elements is generally difficult in single pass layout, but it the tab bar code in ImGui::TabBarLayout already does caching of all tab sizes, so this seems trivial, it seems to work great just adding something along the lines of

    auto left_over_space = tab_bar->BarRect.GetWidth() - tab_bar->WidthAllTabsIdeal;
    float tab_offset = left_over_space > 0.0f ? left_over_space * 0.5f : 0.0;

But maybe there is a more correct way, or it is not deemed a desirable feature.

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

No response

@MirrasHue
Copy link

Would be nice to have a way to control the alignment of text inside a tab as well. I'd like to match the alignment of the window title when it is not docked, with the alignment of the title inside a tab when the window is docked.

@ocornut ocornut added tabs tab bars, tabs style labels May 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
style tabs tab bars, tabs
Projects
None yet
Development

No branches or pull requests

3 participants