Centering of children in horizontal() is broken
- Dominant language
- Rust
- Stars
- 30.6k
- Forks
- 2.1k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 67
Description
**Describe the bug**
In a `ui.horizontal(...)` block, child components are only centered when they are sorted by decreasing size. See this image for an example:

In the above example there are six small buttons, one medium sized and one large, they are all in a single horizontal block (see source code below).
**To Reproduce**
Compile and run the following MRE on `v0.19.0` or latest `master`:
```rust
use egui::{self, RichText};
fn main() {
let options = eframe::NativeOptions::default();
eframe::run_native(
"Horizontal bug",
options,
Box::new(|_cc| Box::new(Test::default()))
);
}
#[derive(Default)]
struct Test;
impl eframe::App for Test {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show(ctx, |ui| {
ui.horizontal(|ui| {
ui.button("S");
ui.button("S");
ui.button(RichText::new("M").size(24.));
ui.button("S");
ui.button("S");
ui.button(RichText::new("L").size(32.));
ui.button("S");
ui.button("S");
})
});
}
}
```
**Expected behavior**
All the child components should be centered regardless of their sizes and ordering. If this isn't possible to fix (due to limitations with immediate mode UIs?) the documentation should be clarified regarding its limitations, and point to a workaround. Currently I overcome this by using `set_height()` but that feels like a brittle solution.
**Desktop (please complete the following information):**
- OS: Ubuntu
- Version: 22.04.1 LTS
Contributor guide
Assessment
This issue has not been assessed yet.