egui icon indicating copy to clipboard operation
egui copied to clipboard

vertical ui in horizontal_wrapped ui fails to wrap

Open rukai opened this issue 2 years ago • 2 comments

Describe the bug

Put this code in the eframe template:

            ui.horizontal_wrapped(|ui| {
                for i in 0..10 {
                    ui.vertical(|ui| {
                        ui.label(format!("{}", i));
                        ui.label("foo");
                        ui.label(format!("{} more", i));
                    });
                }
            });

image

Expected behavior

It should wrap something like this:

image

I constructed this image in an image editor, as I am unable to achieve this functionality in egui.

Desktop:

  • OS: arch linux
  • Browser: firefox and desktop

Occurs on egui 0.22 but I think I also remember this happening last time I played with egui a year or so ago.

rukai avatar Jun 04 '23 07:06 rukai

I noticed that a lot of things don't wrap properly inside of a horizontal_wrapped (I tested, group, vertical and horizontal) but if you add them through a add_sized then it works properly.

It feels like a workaround but yeah...

tomellm avatar Mar 04 '24 08:03 tomellm

Wrapping for Frame inside horizontal_wrapped doesn't work too.

ui.horizontal_wrapped(|ui| {
    for tag in article.tags.iter() {
        Frame::NONE
            .corner_radius(15.)
            .fill(Color32::LIGHT_RED)
            .inner_margin(Margin::symmetric(10, 5))
            .show(ui, |ui| {
                Label::new(RichText::new(tag).color(Color32::WHITE).size(16.)).selectable(false).ui(ui);
            });
    }
});

But if I use only Label it works:

ui.horizontal_wrapped(|ui| {
    for tag in article.tags.iter() {
        Label::new(RichText::new(tag).color(Color32::WHITE).size(16.)).selectable(false).ui(ui);
    }
});

lmaxyz avatar Jun 01 '25 21:06 lmaxyz