Skip to content

Conversation

@JayGeorge
Copy link

More accurately vertically center combobox badges, using progressive enhancement.

The Issue

Currently, the badges have uneven space due to the way browsers trim text (or don't trim, rather).

Solution

We can fix that with progressive enhancement using the new text-box property, which snips the top and bottom of text. We need to apply padding when this happens, which is why I've wrapped the padding in an @supports rule.

Before

Look at the tags carefully and notice how the words are not perfectly in the middle of the badge, vertically.
It's difficult to unsee this—it almost looks like there is larger top padding than bottom padding.

2025-11-21 at 17 53 51@2x

After

The tag text is vertically centered

2025-11-21 at 17 53 35@2x

@jasonvarga
Copy link
Member

Why are we applying this only to badges in the combobox? Wouldn't this happen to a badge used anywhere?

@JayGeorge
Copy link
Author

The short answer is…

Trimming the text doesn't always look better, and for some reason, although it looks better with tags, it looks worse with badges, so I think it's more prudent to opt in to this behaviour carefully.

The long, 3-minute answer is…

Text.Trimming.Tags.mp4

@JayGeorge JayGeorge closed this Nov 24, 2025
@JayGeorge
Copy link
Author

Whoops, I didn't mean to close this

@JayGeorge JayGeorge reopened this Nov 24, 2025
@jasonvarga jasonvarga merged commit 6e18f61 into master Nov 24, 2025
19 checks passed
@jasonvarga jasonvarga deleted the vertically-center-combobox-tags branch November 24, 2025 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants