refactor: modernize badge component to latest MD3 spec#5013
Conversation
Adopt MD3 theme tokens for shape, typography, and sizing: - cornerFull (9999) replaces borderRadius: size / 2 - theme.fonts.labelSmall replaces fontSize: size * 0.5 (11sp, letterSpacing 0.5, fontWeight 500) - Fixed MD3 sizes: 6dp dot, 16dp pill, 4dp padding, 34dp max-width BREAKING CHANGE: size prop removed. Variant is now automatic — no children renders a 6dp dot, children renders a 16dp pill. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…actor/modrnize-badge-component
matkoson
left a comment
There was a problem hiding this comment.
src/components/Badge.tsx:22 @MrMuzyk is removing 'size' a breaking change? can we keep it as deprecated?
generated by an automated pr-review pipe, not written by a human. reply and tag the repo owner if it got something wrong.
…actor/modrnize-badge-component
| /** | ||
| * Size of the `Badge`. | ||
| * @deprecated Size is determined automatically by MD3 variant (6dp dot / 16dp pill). | ||
| * This prop is ignored and will be removed in a future major release. | ||
| */ | ||
| size?: number; |
There was a problem hiding this comment.
Please remove the prop. This will be a major version and we don't want to keep legacy implementations.
| const Badge = ({ | ||
| children, | ||
| size = defaultSize, | ||
| size: _size, |
There was a problem hiding this comment.
What's the point of accepting this prop when it's not used
There was a problem hiding this comment.
To avoid lint errors, it doesn't matter now anyway as we're scrapping it as originally planned
6d29f43 to
d06ee25
Compare
There was a problem hiding this comment.
Pull request overview
Modernizes the Badge component to align with updated Material Design 3 behavior by switching to theme tokens for shape/typography and making the dot vs pill variant automatic based on whether children is provided.
Changes:
- Refactors
Badgesizing/shape/typography to fixed MD3-aligned constants and usescornerFull+theme.fonts.labelSmall. - Removes the
sizeprop and updates callsites to rely on automatic dot (no children) vs pill (with children) rendering. - Updates and expands badge tests and snapshots to cover the new sizing behavior and max-width clipping.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/components/Badge.tsx | Implements MD3 sizing/typography/shape tokens and automatic dot vs pill behavior. |
| src/components/BottomNavigation/BottomNavigationBar.tsx | Updates badge rendering to remove the removed size prop usage. |
| src/components/Drawer/DrawerCollapsedItem.tsx | Updates badge rendering to remove the removed size prop usage and deletes a now-unused constant. |
| src/components/tests/Badge.test.tsx | Removes size-prop test and adds behavioral tests for dot vs pill sizing and clipping. |
| src/components/tests/snapshots/Badge.test.tsx.snap | Updates snapshots to match new MD3 badge styles. |
| src/components/tests/snapshots/BottomNavigation.test.tsx.snap | Updates snapshots to match new badge rendering in BottomNavigation. |
| example/src/Examples/BadgeExample.tsx | Updates example usage to rely on automatic dot vs pill behavior (no size prop). |
| example/src/DrawerItems.tsx | Updates example callsites to remove the removed size prop usage. |
| * The bagde is styled differently based on whether `children` is passed: | ||
| * - Small dot when it doesn't have `children` | ||
| * - Larger pill when it has `children` |
| maxWidth: MAX_LARGE_WIDTH, | ||
| paddingHorizontal: LARGE_PADDING, | ||
| ...labelFont, | ||
| lineHeight: LARGE_SIZE / fontScale, | ||
| }), |
|
Got it, will have a look again and get back with fixed version and some screenshots |


Motivation
Modernizes the
Badgecomponent to the latest MD3 spec by adopting theme tokens for shape, typography, and sizing.Changes
borderRadius: size / 2→cornerFull(9999) fromsrc/theme/tokens/sys/shapefontSize: size * 0.5(8sp at default) →theme.fonts.labelSmall(11sp, letterSpacing 0.5, fontWeight 500)sizeprop → fixed MD3 constants (6dp dot, 16dp pill)paddingHorizontal: 3→ 4dp (MD3 spec)overflow: hiddenBreaking change
The
sizeprop has been removed.Callsites updated
src/components/BottomNavigation/BottomNavigationBar.tsxsrc/components/Drawer/DrawerCollapsedItem.tsx(+ removed unusedbadgeSizeconstant)example/src/Examples/BadgeExample.tsxexample/src/DrawerItems.tsxRelated issue
#4974
Test plan
yarn typescript— cleanyarn lint— cleanyarn test— 737 passed (8 Badge tests: 4 snapshot + 4 behavioral)"999+"clips at 34dp