Skip to content
This repository was archived by the owner on Feb 25, 2026. It is now read-only.
This repository was archived by the owner on Feb 25, 2026. It is now read-only.

[Feature] Add a Reimagined Color Picker #3363

Closed

Description

@robloo

The current WinUI ColorPicker has some deficiencies:

  1. #1637 It is a big control without an adaptive layout. There is no way to switch between horizontal or vertical mode based on available space.
  2. #2309 It does not follow the 'Picker' convention by having a preview button that can be pressed to open an editing flyout
  3. #1659 There is no way to select from a pre-existing list of swatches.
  4. The existing ColorPicker doesn't use NumberBox

Describe the solution

A brand new ColorSwatchPicker control (deriving from ColorPicker) with a totally redesigned layout:

  • Spectrum | to visually select a color on the color spectrum
  • Swatches/Palette | to select a pre-defined color from a palette. This could be from a system colors list, a recent colors list, or a custom-developer supplied list of colors. A configuration will be added so the swatches can be a circle or square.
  • Channels | to create a color using numerical component values. Sliders will be added for each component along with NumberBoxes.

The ColorSwatchPicker will appear as a drop-down button previewing the selected color with a totally redesigned picker within the flyout to edit it.

A custom color pallete (list of swatches) is now supported as well using three properties (and their associated DPs):

        /// <summary>
        /// Gets the list of custom palette colors.
        /// </summary>
        public ObservableCollection<Windows.UI.Color> CustomPaletteColors { get; }

        /// <summary>
        /// Gets or sets the number of colors in each section of the custom color palette.
        /// A section is the number of columns within an entire row in the palette.
        /// Within a standard palette, rows are shades and columns are unique colors.
        /// </summary>
        public int CustomPaletteSectionCount { get; set; }

        /// <summary>
        /// Gets or sets a custom IPalette.
        /// This will automatically set <see cref="CustomPaletteColors"/> and <see cref="CustomPaletteSectionCount"/> 
        /// overwriting any existing values.
        /// </summary>
        public IColorPalette CustomPalette { get; set; }

This requires the implementation of a new interface which I feel is useful enough to be general purpose.

    /// <summary>
    /// Interface to define a color palette.
    /// </summary>
    public interface IColorPalette
    {
        /// <summary>
        /// Gets the total number of colors in this palette.
        /// A color is not necessarily a single value and may be composed of several shades.
        /// </summary>
        int ColorCount { get; }

        /// <summary>
        /// Gets the total number of shades for each color in this palette.
        /// Shades are usually a variation of the color lightening or darkening it.
        /// </summary>
        int ShadeCount { get; }

        /// <summary>
        /// Gets a color in the palette by index.
        /// </summary>
        /// <param name="colorIndex">The index of the color in the palette.
        /// The index must be between zero and <see cref="ColorCount"/>.</param>
        /// <param name="shadeIndex">The index of the color shade in the palette.
        /// The index must be between zero and <see cref="ShadeCount"/>.</param>
        /// <returns>The color at the specified index or an exception.</returns>
        Color GetColor(int colorIndex, int shadeIndex);
    }

Describe alternatives you've considered

The alternative is to modify ColorPicker directly but these changes are too far reaching for existing users of the ColorPicker. Its better to implement this as a brand new control.

Additional context & Screenshots

Below is the implementation of ColorSwatchPicker. Functionally, it is complete as proposed. With styling further work is needed around the sliders to dynamically change the background colors (if possible without too much complexity).

example1

Spectrum Palette Channels
Spectrum Palette Channels1
Channels2

Activity

  1. robloo commented on Jun 24, 2020

    @robloo
    ContributorAuthor

    I should add, I intend to implement this control myself. I'm looking for more feedback before coding starts though.

  2. Kyaa-dost commented on Jun 24, 2020

    @Kyaa-dost
    Contributor

    @robloo seems like an interesting feature. Let's see what our devs think about this and then you can proceed with the PR 🚀

  3. niels9001 commented on Jun 24, 2020

    @niels9001

    Great idea!

    Having a 'compact' mode (where the selected color is shown) would be great. As you mentioned in the OT, a DropDown button could work for that. This is how we implemented this in PowerToys:

    FZColors

    And this is a UX proposal for a Windows color picker tool: a redesigned colorpicker would be useful there as well (more info on this in microsoft/PowerToys#864):

    Colorpicker_Twitter

  4. robloo commented on Jun 24, 2020

    @robloo
    ContributorAuthor

    @niels9001

    I will definitely implement the drop down / preview functionality. I already have a control for this implementing it in one of my apps. It also has a checkered background for transparency. Bottom line, one of the main drivers of this is to get a more usable color picker to put in apps as soon as possible. We need to close the feature gap with user expectation.

    The second idea is very interesting. It previews a bunch of different tints and shades which is useful. I'll have to think if that can be worked into the existing ideas. Once I have a prototype (which might be some weeks) I would like your feedback on ideas like this.

  5. niels9001 commented on Jun 24, 2020

    @niels9001

    @niels9001

    I will definitely implement the drop down / preview functionality. I already have a control for this implementing it in one of my apps. It also has a checkered background for transparency. Bottom line, one of the main drivers of this is to get a more usable color picker to put in apps as soon as possible. We need to close the feature gap with user expectation.

    The second idea is very interesting. It previews a bunch of different tints and shades which is useful. I'll have to think if that can be worked into the existing ideas. Once I have a prototype (which might be some weeks) I would like your feedback on ideas like this.

    That would actually be a pretty neat addition: having a palette based on the selected color or swatch.

    If you want me to help to do some UX mocks, let me know.

  6. robloo commented on Jun 24, 2020

    @robloo
    ContributorAuthor

    Yes, I definitely see the value. Actually, this (small palette) preview could probably be added as a preview method in ALL tabs. Instead of previewing only the selected color, the additional shades would also be shown. That would allow quickly increasing/decreasing shade or tint in a visual way.

    For calculating the tints and shades what algorithm did you use? I don't want to just randomly mix in some white and black and wonder if there are usability studies on different thresholds?

    UX is kind of a joy for me too. Personally, I find it's best to R&D this stuff in controls directly though. I would like to put my ideas down first before getting wider feedback. Your help refining them (or even changing them) at that point would be invaluable.

  7. niels9001 commented on Jun 24, 2020

    @niels9001

    Yes, I definitely see the value. Actually, this (small palette) preview could probably be added as a preview method in ALL tabs. Instead of previewing only the selected color, the additional shades would also be shown. That would allow quickly increasing/decreasing shade or tint in a visual way.

    For calculating the tints and shades what algorithm did you use? I don't want to just randomly mix in some white and black and wonder if there are usability studies on different thresholds?

    UX is kind of a joy for me too. Personally, I find it's best to R&D this stuff in controls directly though. I would like to put my ideas down first before getting wider feedback. Your help refining them (or even changing them) at that point would be invaluable.

    I translated the Windows.UI.Color into a HSV value, and just played around with the V value. There are much better ways to do it, this was a 5 min hack to get the concept right :)

  8. mdtauk commented on Jun 24, 2020

    @mdtauk

    You could perhaps employ the same colour maths that is used to generate the light and dark shades of an accent colour.

  9. robloo commented on Jun 24, 2020

    @robloo
    ContributorAuthor

    I decided, for now, to start implementing these ideas into an existing app's custom color picker. That will speed up prototyping a lot and it allows for quickly adding these features to my own app without waiting for Microsoft. But it also means I'll have images to start getting feedback on quite a bit faster. When we have direction from Microsoft I can pull the code into the toolkit.

    I also want to add an IPalette interface that defines a 'grid' or 'chart' of colors.

    int ColorCount;
    int ShadeCount;
    Color GetColor(int colorIndex, int shadeIndex);

    What will this do? It will make it easy to define, use and share color palettes like material design, flat UI, etc. You will be able to set the Palette of the color picker all at once instead of having to provide a list of Colors with no knowledge of how to arrange them. This might not make it outside my apps but I think it would be useful to prototype and get feedback on. It might also be useful in the framework someday as a higher level structure for a chart of colors.

  10. robloo commented on Jun 25, 2020

    @robloo
    ContributorAuthor

    Here is what I have in mind for the Components tab. This is non-functional but it's real XAML and represents what I'm planning. Please let me know any comments. @mdtauk I used some of your previous mock-ups as well.

    image

    It would also be good to have the background of the sliders dynamically change. Each slider would show a gradient. I haven't decided whether to implement that in this version. I'll probably get to more of this during the weekend.

    Note that the default NumberBox and ComboBox heights are different too which I find strange.

    Edit: Also note that the preview color along with +/-2 shades will be at the bottom which is not pictured.

  11. michael-hawker commented on Jun 25, 2020

    @michael-hawker
    Member

    Hey all, love the enthusiasm here. I know we do have some Color value helpers in the toolkit for some of these different HSV scenarios.

    As for the re-implementing ColorPicker, especially with the existing proposals for WinUI, I really think improving the platform based control would be the best option still here.

    @robloo I'm assuming you're more comfortable with C# vs. C++ and thus choosing to propose this to the Toolkit based on that? If so, I do know WinUI still does some prototyping in C#, so there could still be an opportunity to work with them to build out the vision and then work towards improving the existing controls.

    It could maybe make sense to add the picker dropdown here in the meantime. However we'd still want to rely on the inbox ColorPicker vs. the WinUI one (as we don't have a dependency in our main package on WinUI).

    I did a quick experiment here that looks promising:

            <DropDownButton AutomationProperties.Name="Color" CornerRadius="2">
                <DropDownButton.Content>
                    <Border Width="20" Height="20" Margin="-6,-4,0,-4" CornerRadius="2">
                        <Border.Background>
                            <SolidColorBrush Color="{Binding Color, ElementName=ColorPicker}" />
                        </Border.Background>
                    </Border>
                </DropDownButton.Content>
                <DropDownButton.Flyout>
                    <Flyout Placement="BottomEdgeAlignedLeft">
                        <ColorPicker x:Name="ColorPicker"/>
                    </Flyout>
                </DropDownButton.Flyout>
            </DropDownButton>

    I could see us inheriting from ColorPicker and exposing the Flyout Placement value in a simple templated control.

    FYI @ranjeshj @stmoy @chingucoding

  12. 46 remaining items

  13. robloo commented on Jul 7, 2020

    @robloo
    ContributorAuthor

    @mdtauk I had a similar thought and it's why I designed the IColorPalette interface to be what it is. Any class can implement this interface to provide a color palette for the control and have it visually represented correctly in the color picker. There is no reason the implementing class couldn't generate colors dynamically as well!

    In my own apps I've already added several different color palettes. I'm only providing the Windows Color palette for this PR though: https://github.com/windows-toolkit/WindowsCommunityToolkit/blob/2de382f3f31d90fe1f6953b9c15dce201ad21baa/Microsoft.Toolkit.Uwp.UI.Controls/ColorPickerButton/WindowsColorPalette.cs

    image

    I've taken some liberties with windows color ordering that I describe in detail in the linked file. You might be interested in looking into it and I would value your feedback.

    Also note that the new properties for this picker are purposely name 'CustomPalette...' instead of 'Palette...' as multiple palettes may be supported in the future (windows colors, recent colors, custom palette all in different sections/expanders visible at the same time). So hopefully this is future-proofed.

  14. robloo commented on Jul 8, 2020

    @robloo
    ContributorAuthor

    @niels9001 Have you had a chance to look at this recently? There is a PR for it you can download and build as well. I know you are working with your ColorPickerUX which looks awesome. However, your feedback and lesson's learned are quite useful wrapping up the first version of this control.

  15. niels9001 commented on Jul 12, 2020

    @niels9001

    @robloo Sorry for the late reply. I did some tweaks:

    • Acrylic backdrop behind the pivot tabs - this separates the tabs slightly more from the content of the pivot items.
    • Added CornerRadius 4 to a lot of elements, so it's inline with WinUI's new style.
    • Tweaked the Slider2 thumb so it's round.
    • Updated a lot of spacing related stuff: using margins that are multipliers of 12. (the slider page still needs some tweaking tbh).
    • Changed Bold labels to SemiBold
    • Added a 2px gap between in the colors gridview (so it's inline with the color picker that is in the W10 Settings app).

    Let me know what you think!

    ColorSlidersButton

    ColorSwatchPicker.zip

  16. robloo commented on Jul 12, 2020

    @robloo
    ContributorAuthor

    Thanks a lot for the feedback!

    Acrylic backdrop behind the pivot tabs - this separates the tabs slightly more from the content of the pivot items.

    I like the pivot header background being a different color. Acrylic was a good thought to add here.

    Added CornerRadius 4 to a lot of elements, so it's inline with WinUI's new style.

    The CornerRadius of 4 is only for overlays. Controls use 2. I realize 4 looks nice but this seems to violate the design convention. Any thoughts on this? Additionally, I was keeping all color swatches 'square' which seems to be the windows convention. I agree that the rounded corners in the palette and mini-preview look nicer but doesn't this violate the windows styling?

    Tweaked the Slider2 thumb so it's round.

    This was already done in the PR. As I mentioned to @mdtauk, I also had the thought originally to make it round fully inside the track. However, I was trying to avoid the iOS style and use the style of the existing color picker. The existing color picker has a bar that extends outside of the track. This was also done so that the thumb is visible no matter what the color of the track is. To solve this problem of color visibility/contrast, I have the thumb dynamically change color between black/white just like the color spectrum. This required adding a new converter which you can see in the PR code -- I will make 1 additional improvement with that converter as well (remove the need for code-behind to handle transparency).

    Updated a lot of spacing related stuff: using margins that are multipliers of 12. (the slider page still needs some tweaking tbh).

    I think we have a different eye for spacing and I prefer compact themes. I'm not a big fan of the difference in spacing at the top of a pivot item vs the bottom. What is the reasoning behind it? The slider spacing also looks better to me evenly distributed.

    Changed Bold labels to SemiBold

    I'm glad you noticed this. I was going back/forth on whether these should be bold at all. They still seemed slightly off to me but semi-bold looks great.

    Added a 2px gap between in the colors gridview (so it's inline with the color picker that is in the W10 Settings app).

    The reason I didn't add spacing between swatches was because some palettes have a lot more than 16 colors in them. The default palette is now the Windows Color Palette as well. If you try to add that spacing to a flat UI palette it's not going to work. So I dropped the spacing. This could theoretically be made configurable with another converter and a maximum count of colors before spacing is removed -- seems like too much complexity though. Other color pickers also do not have this gap. Separately note that the selected item template is going to be matched with the settings app (check mark, on selected color).

    Finally, a LOT of additional changes were made to the PR #3379 compared to the .zip file I sent. The RGB/HSV selection is now togglebuttons as well. For my own sanity can we all use that code from now on? I'll pull over the changes you've made here that we agree on later today into the production code.

    Edit: I also don't think it's a good idea to make the spectrum smaller although I agree for the ring it looks better. In my opinion it should always be the maximum size possible. When the spectrum is a box it's going to look strange not aligned with the sliders height. There are also some spectrum sizing bugs that I have to work around.

  17. niels9001 commented on Jul 12, 2020

    @niels9001

    Thanks a lot for the feedback!

    Acrylic backdrop behind the pivot tabs - this separates the tabs slightly more from the content of the pivot items.

    I like the pivot header background being a different color. Acrylic was a good thought to add here.

    Added CornerRadius 4 to a lot of elements, so it's inline with WinUI's new style.

    The CornerRadius of 4 is only for overlays. Controls use 2. I realize 4 looks nice but this seems to violate the design convention. Any thoughts on this? Additionally, I was keeping all color swatches 'square' which seems to be the windows convention. I agree that the rounded corners in the palette and mini-preview look nicer but doesn't this violate the windows styling?

    Tweaked the Slider2 thumb so it's round.

    This was already done in the PR. As I mentioned to @mdtauk, I also had the thought originally to make it round fully inside the track. However, I was trying to avoid the iOS style and use the style of the existing color picker. The existing color picker has a bar that extends outside of the track. This was also done so that the thumb is visible no matter what the color of the track is. To solve this problem of color visibility/contrast, I have the thumb dynamically change color between black/white just like the color spectrum. This required adding a new converter which you can see in the PR code -- I will make 1 additional improvement with that converter as well (remove the need for code-behind to handle transparency).

    Updated a lot of spacing related stuff: using margins that are multipliers of 12. (the slider page still needs some tweaking tbh).

    I think we have a different eye for spacing and I prefer compact themes. I'm not a big fan of the difference in spacing at the top of a pivot item vs the bottom. What is the reasoning behind it? The slider spacing also looks better to me evenly distributed.

    Changed Bold labels to SemiBold

    I'm glad you noticed this. I was going back/forth on whether these should be bold at all. They still seemed slightly off to me but semi-bold looks great.

    Added a 2px gap between in the colors gridview (so it's inline with the color picker that is in the W10 Settings app).

    The reason I didn't add spacing between swatches was because some palettes have a lot more than 16 colors in them. The default palette is now the Windows Color Palette as well. If you try to add that spacing to a flat UI palette it's not going to work. So I dropped the spacing. This could theoretically be made configurable with another converter and a maximum count of colors before spacing is removed -- seems like too much complexity though. Other color pickers also do not have this gap. Separately note that the selected item template is going to be matched with the settings app (check mark, on selected color).

    Finally, a LOT of additional changes were made to the PR #3379 compared to the .zip file I sent. The RGB/HSV selection is now togglebuttons as well. For my own sanity can we all use that code from now on? I'll pull over the changes you've made here that we agree on later today into the production code.

    Edit: I also don't think it's a good idea to make the spectrum smaller although I agree for the ring it looks better. In my opinion it should always be the maximum size possible. When the spectrum is a box it's going to look strange not aligned with the sliders height. There are also some spectrum sizing bugs that I have to work around.

    Good catch. Agree on 2 vs. 4, I picked the wrong number there. Since WCT didn't move towards WinUI at all we may want to skip it for now. Everything is square so having a control with rounded everything is maybe not really consistent.

    Spacing on GridView makes sense. Making this configurable would be nice though.

    As I mentioned, the spacing was a bit all over the place. I defaulted to 12px now, and skipping to 24 in between chunks of information. This seems to work out for the first two pivots. The slider page needs some more work. I would however opt for more spacing between the first row and the chunk of sliders, since they belong together.

    Another question I had: I wasn't able to check out the PR just yet - but I could imagine the Pivot control goes away entirely when I'd only want to see the colorpicker, and not the other two items. Correct?

  18. robloo commented on Jul 12, 2020

    @robloo
    ContributorAuthor

    Good catch. Agree on 2 vs. 4, I picked the wrong number there. Since WCT didn't move towards WinUI at all we may want to skip it for now. Everything is square so having a control with rounded everything is maybe not really consistent.

    Ok, if we have the thought perhaps we can revisit this in 6-9 months once WinUI 3.0 is out and everyone has moved over to its standardized styling.

    As I mentioned, the spacing was a bit all over the place. I defaulted to 12px now, and skipping to 24 in between chunks of information.

    Generally, I like grouping related information by additional spacing as well. In this case 12px across the board seems to look better for me though (expect for the slider page). I thought I was pretty consistent with that 12px -- perhaps the code you have is just too old compared to the PR or I'm missing something. Let's start talking about specific spacing and margins so we can resolve this.

    The slider page needs some more work. I would however opt for more spacing between the first row and the chunk of sliders, since they belong together.

    Agree on that, I'll see how it looks to keep 24px above and below the sliders (as a group) only.

    Another question I had: I wasn't able to check out the PR just yet - but I could imagine the Pivot control goes away entirely when I'd only want to see the colorpicker, and not the other two items. Correct?

    This isn't implemented yet but yes, tabs should disappear when they aren't needed and go away entirely if only one tab is needed. That said, Pivot has a bug where settings the visibility of a PivotItem to collapsed does not remove it from the pivot. This could be an issue to implement anything here and I haven't figured out what I'm going to do about it yet. Edit: I'm also going to have to add an IsPaletteVisible property I think.

  19. robloo commented on Jul 12, 2020

    @robloo
    ContributorAuthor

    @niels9001

    I update the styling in the PR:

    • Acrylic backdrop behind the pivot tabs - this separates the tabs slightly more from the content of the pivot items.
    • Added CornerRadius 2 to the mini-preview (it does look better)
    • Changed Bold labels to SemiBold

    The code was changed to optimize things here and there.

  20. Sergio0694 commented on Sep 17, 2020

    @Sergio0694
    Member

    Was reading a blog post about the new WinUI-powered Syncfusion controls, and noticed they have a new DropDownColorPicker control as well, which conceptually seems very very similar to this one, so I figured I'd mention it.
    The link to the blog post is here, and here's a screenshot of that control in particular:

    image

    NOTE: just sharing this here as I thought it might be interesting/relevant to the conversation. I'm not actually suggesting any particular action due to this announcement and this message is not meant to be a "there's that, so let's just drop this proposal".

  21. robloo commented on Sep 17, 2020

    @robloo
    ContributorAuthor

    Its always good to see what others are doing! I think the ColorPickerButton has some key design differences that address additional issues (like overall size, separation of functionality, palette, etc.) that makes it a more valuable control at this point. Of course I'm biased 😀

  22. ghost closed this as completedin #3379on Nov 9, 2020
  23. ghost added a commit that references this issue on Nov 9, 2020
    8315ffb
  24. added this to the 7.0 milestone on Jan 6, 2021
  25. ghost locked as resolved and limited conversation to collaborators on Mar 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions