How to resize egui-sliders? (or any widgets, really)

Anyone have any examples of resizing an egui slider? Or other similar widgets (besides Labels, which have RichText to resize). All of the examples I've found, just take the default. I realize there's the add_sized() method, but that just seems to set the margins/padding - the actual slider doesn't expand to take up the given space.

For that matter, are there any detailed docs on setting up egui UIs? Other than egui - Rust, which I have gone over in detail. But even with that, and the examples, there's just so many questions I haven't been able to answer.

1 Like

It's almost like rubber-ducking - just after posting, I found an example (in an Issue) that had enough information to piece a solution together. Layout stuff

The default Slider size is set by crate::style::Spacing::slider_width.
ui.style_mut().spacing.button_padding = (16.0, 64.0).into();

Eventually gave me:

ui.style_mut().spacing.slider_width = (300.0);

Which, note, changes all Sliders, not just one, but that's at least something.

I'm not marking it solved, because it's not quite a solution - changing the global slider-width sort of works, but there has to be a way of resizing individual widgets, that I'm not understanding.

For that matter, are there any more detailed docs (than the official), that would explain how to do this?

Note that Ui is passed to the closures of the container widgets, and you can override settings within each closure. So you might do:

ui.horizontal(|ui| {
    ui.spacing_mut().slider_width = 300.0;

Or create a egui::Area and get ui from the show method, etc.

I don't know of other docs aside from the official source. I've been finding a lot of example projects using egui since it's bundled with other frameworks, like bevy for example. The github discussions page is helpful too.

Ah, so you can do style-configuring, per-closure (or per-grouping of components), that's good to know. (At least for sliders - presumably there's other ways of sizing other types of widgets).

That answers my question about per-widget sizing, thanks.

And yeah, I've been looking at bevy examples also, that's where I started using egui. But much as I like code-examples, they don't always cover my desired use-case.

Also, neither the official docs nor examples, are really giving me an understanding at a conceptual-level, of how to put together and configure, all of the pieces of egui. So it goes.