IssueRaiser

CSS-like styling

Some half-finished ideas around how to improve the styling and theming story for egui. # Background Styling for egui is currently supplied by `egui::Style` which controls spacing, colors, etc for the whole of egui. There is no convenient way of changing the syling of a portion of the UI, except for changing out or modifying the `Style` temporarily, and then changing it back. We would like to have a system that can support CSS-like selectors, so that users can easily style their ui based on the *Style Modifiers* (see below): It would be very beneficial if such styling could be set in a single text file and live-loaded. # Action plan * [x] https://github.com/emilk/egui/issues/3936 * [x] https://github.com/emilk/egui/pull/4232 * [x] https://github.com/emilk/egui/issues/4019 * https://github.com/emilk/egui/issues/7586 * [x] Implement a first iteration of `StyleModifiers` ("classes") * [ ] Implement the `WidgetStyle` selection it via a plugin system (`ThemePlugin`). * [ ] Cache the output of the `ThemePlugin` * [ ] Implement some hierarchical "class" system and add that as part of `StyleModifiers` * [ ] The actual CSS rule engine, which can now be fully a separate crate, and opt-in # Proposal ## Style modifiers Here are some things that could influence the style of a widget: - widget type (button, slider, label, …) - interact state (disabled, inactive, active, hovered, active) - text modifier (header, small, weak, strong, code, …) - per-`Ui` class (”settings_panel”) - p

Posted by emilk on Aug 28, 2023, 3:00 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.2,000 issues0 comments

ux (Software)

CSS-like styling

emilkAug 28, 2023, 3:00 PM

Some half-finished ideas around how to improve the styling and theming story for egui. # Background Styling for egui is currently supplied by `egui::Style` which controls spacing, colors, etc for the whole of egui. There is no convenient way of changing the syling of a portion of the UI, except for changing out or modifying the `Style` temporarily, and then changing it back. We would like to have a system that can support CSS-like selectors, so that users can easily style their ui based on the *Style Modifiers* (see below): It would be very beneficial if such styling could be set in a single text file and live-loaded. # Action plan * [x] https://github.com/emilk/egui/issues/3936 * [x] https://github.com/emilk/egui/pull/4232 * [x] https://github.com/emilk/egui/issues/4019 * https://github.com/emilk/egui/issues/7586 * [x] Implement a first iteration of `StyleModifiers` ("classes") * [ ] Implement the `WidgetStyle` selection it via a plugin system (`ThemePlugin`). * [ ] Cache the output of the `ThemePlugin` * [ ] Implement some hierarchical "class" system and add that as part of `StyleModifiers` * [ ] The actual CSS rule engine, which can now be fully a separate crate, and opt-in # Proposal ## Style modifiers Here are some things that could influence the style of a widget: - widget type (button, slider, label, …) - interact state (disabled, inactive, active, hovered, active) - text modifier (header, small, weak, strong, code, …) - per-`Ui` class (”settings_panel”) - p

Comments (0)

No comments yet. Start the discussion.

Comment on this issue