Skip to content

UI: use Text component for Badge typography#77295

Merged
ciampo merged 6 commits intoWordPress:trunkfrom
shrivastavanolo:update/badge-text
Apr 14, 2026
Merged

UI: use Text component for Badge typography#77295
ciampo merged 6 commits intoWordPress:trunkfrom
shrivastavanolo:update/badge-text

Conversation

@shrivastavanolo
Copy link
Copy Markdown
Contributor

@shrivastavanolo shrivastavanolo commented Apr 14, 2026

What?

Part of the effort in #76929
(Also, similar changes to #76642)

Refactors the Badge component to use the Text component for typography.

Why?

Typography values (font-family, font-size, font-weight, line-height) were duplicated in the badge's stylesheet rather than being owned by a single source of truth. Using Text with variant="body-sm" centralises this so the badge stays consistent with the rest of the design system automatically.

How?

  • Replaced the useRender hook pattern with an explicit JSX return wrapping content in Text variant="body-sm"
  • Removed the four typography declarations from style.module.css since they are now inherited from Text

Testing Instructions

Testing Instructions for Keyboard

  1. Open Storybook and navigate to Design System / Components / Badge
  2. Verify all Badge stories render with the same typography as before (correct font size, weight, and line height)
  3. Check each intent variant story — confirm colors are unaffected

Use of AI Tools

Used Claude (claude.ai) to assist with code review and PR description drafting. All changes were reviewed and authored by me.

@github-actions github-actions bot added the [Package] UI /packages/ui label Apr 14, 2026
@shrivastavanolo shrivastavanolo marked this pull request as ready for review April 14, 2026 10:56
@shrivastavanolo shrivastavanolo requested a review from a team as a code owner April 14, 2026 10:56
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 14, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: shrivastavanolo <shreya0shrivastava@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Comment thread packages/ui/src/badge/badge.tsx Outdated
@ciampo ciampo added the [Type] Enhancement A suggestion for improvement. label Apr 14, 2026
Comment thread packages/ui/src/badge/badge.tsx Outdated
Comment on lines +17 to +23
variant="body-sm"
className={ clsx(
styles.badge,
styles[ `is-${ intent }-intent` ],
className
),
children,
} ),
} );

return element;
) }
{ ...props }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move variant after the {...props} spread, to make sure it can't be overridden

Comment thread packages/ui/CHANGELOG.md Outdated
- `Dialog`, `AlertDialog`, `Tooltip`, `Select`: Add `container` prop to `Popup` for custom portal targets ([#77163](https://github.com/WordPress/gutenberg/pull/77163)).
- Add defensive styles against global WordPress stylesheets like common.css and forms.css ([#76783](https://github.com/WordPress/gutenberg/pull/76783)).
- `VisuallyHidden`: Improve Storybook stories and documentation for the `render` prop composition pattern.
- `Badge`: Use `Text` component for typography ([#77295](https://github.com/WordPress/gutenberg/pull/77295)).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can move this under internal, since there are effectively no changes for consumers of the package

Copy link
Copy Markdown
Contributor

@ciampo ciampo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

Thank you!

@ciampo ciampo enabled auto-merge (squash) April 14, 2026 13:08
@ciampo ciampo merged commit 7b87ea3 into WordPress:trunk Apr 14, 2026
40 checks passed
@github-actions github-actions bot added this to the Gutenberg 23.0 milestone Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] UI /packages/ui [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants