-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert to component: Badge #61106
Comments
Indeed, that seems useful. However it's probably important to do that effort only if and when the need for this chip emerges organically. |
In addition to badge fields in data views, another potential use case is #57763. But yes, no need to rush for only one or two applications. |
Another potential use case for the badge: #38277 (comment) |
Hi @jameskoster 👋
Let me know your thoughts on this. Thanks |
@jameskoster could we please add a version of this badge component where we have the option to include an icon (before OR after the text)? |
@jameskoster @Vrishabhsk I worked on the component design a bit, and here's my proposal. To cover a range of usecases we need to have a few different colour Base colours Background Foreground And in that way, we will have all colour badges, which all pass the accessibility tests. In terms of design they have (but I'll spec that when we have the final designs) 8px padding left and right, 4px top and bottom. We are thinking about adding a larger variant as well, just FYI.
@orcunomattic we were just talking about this with @jameskoster ! Yes, there will be a variant with an icon (on the left and on the right). I'll add them as symbols once we are all aligned on this! |
I'd support the variant with icon and clear usage guidelines to educate that the meaning of the variants can't be communicated only via the color. From an accessibility perspective, color alone isn't sufficient. Typically, the meaning of the various colors may be summarized as follows:
All these meanings must be communicated either via a clearly recognizable shape or via the text used within the badge. Useers must be able to understand 'hey this is a warning', or 'hey this is an alert' etc. |
Hi @orcunomattic @rogermattic @afercia 👋 Thanks for your input on the component
Let me know your thoughts on this. Thanks |
I'm not sure about offering an icon and context as separate props. It's not 100% clear that we need an icon affordance just yet, so we might be better off adding that later. For the initial implementation perhaps icon usage is built into the context prop? IE an icon is only displayed when context is one of; warning, danger, success? @afercia would it be acceptable for a lack of icon to be indicative of an informational badge? Here's a quick mockup exploring icons and shapes: @rogermattic transparency can lead to contrast issues down the road if the badges ever appear on non-white backgrounds. Do you think there's a way to apply color without using transparency? |
Thanks for your feedback!
For the current use case I’m exploring, an icon isn’t necessary, but believe others might benefit from a variant with one. I can look into this further and gather evidence and examples to support the need for an icon variant.
With a different perspective, I believe we’re accessibility-safe even without the icon. The text label, paired with the color, ensures accessibility for users. That said, I still think an icon would be a nice addition as it adds a helpful visual clue and enhances the meaning. Actually, the opposite is true for accessibility concerns: when we have an icon and color but no text to clarify the meaning, it could be considered less accessible.
Great point! I realize I could've been clearer in the specs (honestly didn’t expect things to move this fast!). By ‘transparency,’ I was only referring to the transparency of the color on the layer above white. I completely agree that the badge itself shouldn’t be transparent. And while it’s designed primarily for use on a white background, we should also consider cases where it might appear on light gray or similar shades, where the color should remain consistent.
@Vrishabhsk thank you for your speedy work on this! |
@jameskoster a generic, informational badge may not use any icon. However, in Core the 'info' notices use a blue color and I'd recommend consistency.
@rogermattic can you please add more context? I'm not sure whether the 'text label' you mention is a sort of text prefix e.g. 'Error:', 'Warning:' etc. that is prefixed to all badges content. In that case, without an icon, this prefix should be required. The distinction between the badge types can't be only conveyed using color. Ideally, badges should provide cues through color, icon, and text. For screen reader users, some textual content is required to distinguish the badge type. This issue is very similar to the one discussed on Trac for the admin notices. See this trac ticket: https://core.trac.wordpress.org/ticket/50442. I would recommend to give that a read to better understand color alone is insufficient. Quick tip: |
Cc @joedolson for any additional feedback he may want to bring in. |
I have added a few more commits to the |
I believe the content of these It seems we might have different use cases in mind for these
That's a great point and a helpful example! For notices, I agree that color plays a primary role—indicating 'Error,' 'Warning,' etc.—so communicating the color itself is essential. In this case, icons will likely be important to reinforce the message. |
I think most of the feedback I might add has already been added via the references to track ticket 50442; but in general, I agree that the combination of color and icon is fairly crucial for having a consistent perceivability of the value. The text itself should generally convey the significant meaning of the badge, no matter what color or icon is used; though obviously some text can be ambiguous. However, if we want to increase the recognition affordance to allow improved at-a-glance recognition of the badges, then we need to have both color, context and icon, so that improvement is available to all users. When an icon is present, the context can be the icon; the text would simply serve as the alternative text for that icon - just to clarify that I'm not recommending that the context string always be visibly present. |
Good point. I;d argue those are two different cases:
Yes but we can't enforce strict rules about the type of content. Consumers of this component may use it with any content so that we can't guarantee a correct usage. Overall, wherever color is used to communicate meaning, there should be an alternative way to communicate that meaning. |
Excellent examples and I do agree :) A But I do think that we also need a generic variant as you described it above! So ideally we have both variants :)
Agreed! But it seems to me that what we also cannot enforce is the right use of icons / or / the use of right icons, so providing both variants and some guidance is probably the way to go. WDYT? |
I think we can if the icon is a feature of the What's less clear to me is how colors should be applied to |
🙌 awesome idea.
Great point @jameskoster ! I think, when
I'll work on this asap, and get back here with an update:
|
Coming back with some updates! Here are the different badge variants: It would be great to get your general feedback, and I’m especially interested in your thoughts on the following:
Additionally, I considered a gray badge variant with a toggle tip icon, though I’m still debating whether that’s necessary. I wonder how we can ensure this isn't overused. Perhaps we should set a rule to always place a toggle tip in the column header if needed additional explanation. Looking forward to hearing your feedback! cc: @jameskoster @Vrishabhsk |
Thanks, @rogermattic @jameskoster for the work done here. The mockup looks pretty accurate as per our use case Wanted to summarize a few things here :
|
Thanks for the continued work on this @rogermattic :) My overarching feedback would be to keep things as simple as possible for the initial implementation; it's much easier to add features later as needed, than to remove them. In that train of thought:
Should there be an @Vrishabhsk Thanks for summarising, this is helpful. Based on my comments above I think we can simplify quite a bit:
One other comment on the design; the current 'badges' are 20px tall which ensures they neatly align with the most common text styles (20px line-height) without affecting layout. See the screenshot below for a demo of what I mean. It might be nice to preserve this detail if we can. |
@Vrishabhsk @jameskoster thank you for reviewing and working on this!
Agreed!
Agreed!
Are you okay with the icons I suggested?
I have some use case that I can describe for this; can I go ahead and open a separate issue for that?
I agree, for now this can be a 1:1 reference, until we prove the need for the
I used the smallest line height $font-line-height-x-small and the $font-size-small font size, which corresponds to the Body Small text style in Figma (set at 12/16px). Adding a 4px padding on the top and bottom brings the total height to 24px. I think of it this way rather than as a fixed height. In my opinion, it looks fine, though it’s a bit tight in the screenshot you attached. However when I apply these settings in the table context, it feels a bit cramped. WDYT? Also I think the variants with icons look really tight with these settings and I don't think we should go any smaller with the icon size? |
Hi @jameskoster @rogermattic 👋
Let me know your thoughts on this. Thanks |
|
Yes please!
Looking at the screenshot in @Vrishabhsk's comment above, I'd say the The What do you think @rogermattic? |
Yes yes, all called a
Agreed 100%. The warning icon surprised me too. I used the WordPress icons in my designs, just the outlined not filled) variants. But I do see it now that we would probably benefit from having a bit more consistency between the icons, exactly like you said @jameskoster :
I cannot unsee it now :D But I wonder, if I introduce some icons similar to what you proposed in your comment, would I need to add them to the Gutenberg library? I feel like we could use the circle for |
Yes, we can do it as a part of the PR :)
That sounds like a good place to start :) |
@jasmussen noticed that the |
Hi @jameskoster @rogermattic 👋
Let me know your thoughts on this. Thanks |
Thanks for the update @Vrishabhsk. Looking at this I wonder if the error should use the triangular outline as it seems more severe. The designs could use some tweaks to the footprints and details like roundedness align. I'll push some updates to the PR :) |
@jameskoster thanks for working on these icons and apologies @Vrishabhsk for the lack of my guidance in the meantime. Just wanted to double-check, we have 4 variants with icons, right?
and one without an icon:
Is this possible to use the red, yellow and green also without an icons? |
@rogermattic Not in the current implementation. Given the accessibility concerns and overall coherence as a design system, I'm also leaning toward keeping the color and intent closely coupled. Green and red feel kind of safe in this regard, but once we allow no-icon usage of blue and yellow I feel like we would quickly see a lot of usage straying from the original intents reinforced by the icon. The colors would lose meaning once we have ecosystem tenants using the colors arbitrarily. One can always just use the neutral variant and override the color with their own CSS class, but that's purely a consumer decision and not officially part of the design system. Would that be reasonable? |
A recently-merged data views feature allows consumers to display field values as a 'badge' in grid layout. This is utilised in the Patterns page to communicate sync status:
This element will likely have applications beyond data views, so it may be worth extracting and converting to a reusable component.
The text was updated successfully, but these errors were encountered: