emilk / emilk/egui

Configuration options for color picker layout/style

Open
#5,153 1 comment 1 reaction 0 assignees View on GitHub
egui feature
Dominant language
Rust
Stars
30.6k
Forks
2.1k
Avg merge
1d 9h
Merged PRs (30d)
72

Description

**Is your feature request related to a problem? Please describe.**
Using `egui::widgets::color_picker::color_picker_hsva_2d` (or similar) by itself results in a color slider that's much smaller than the row with the drag values:
![image](https://github.com/user-attachments/assets/1db5238e-4811-4e97-af0e-1ed1f30ee1a2)

This is because the color area draws its size from `style.spacing.slider_with` (which is slightly unintuitive if you haven't looked at the code / know that the area is a slider). This can be scaled up in a child UI
```rust
ui.scope(|ui| {
ui.spacing_mut().slider_width = 220.0;
egui::widgets::color_picker::color_picker_hsva_2d(
ui,
&mut egui_color,
egui::color_picker::Alpha::Opaque,
);
});
```

to get reasonable results:
![image](https://github.com/user-attachments/assets/16bc53be-4034-47a2-8e8f-3690e8765db7)

However, I don't actually need the ability to change the color format or to copy the color, and would prefer to keep the color slider small.

**Describe the solution you'd like**
I would like the ability to configure the style and layout of the color picker widget, so that you can specify:
- the size of the color slider in a more explicit fashion
- whether or not the color format is shown
- whether or not the copy button is shown
- whether or not the raw values of the color are shown

I suspect the best way to do this would be to convert it into a formal `Widget` so that it can be configured and placed as the user requires.

In addition to this, breaking apart the widget into its constituent components and exposing them would help users pick and choose what they want. For example, making `color_slider_2d` (or its `Widget` equivalent) public would be perfect for what I need.

**Describe alternatives you've considered**
The only solution I can see that would work externally would be to copy the code from `egui` or to fork it, neither of which is ideal. A short-term fix would be to make all of the relevant constituent functions public, so that they can be used without using the full `color_picker`.

**Additional context**
I believe the disparity in size between the color picker and the value row was exacerbated by #2734.

Contributor guide

Open the contributing guide

Research direction

Start with the public color_picker_hsva_2d entry point and inspect how it uses the color slider and surrounding controls. Review the related color_slider_2d reference in the issue, then determine how configurable sizing, format/value display, and copy-button options should be exposed. Done means users can select the desired layout without copying or forking egui code.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.