[material-ui][Badge] Use inline CSS variables for anchorOrigin/overlap positioning#48549
Merged
siriwatknp merged 6 commits intoMay 20, 2026
Merged
Conversation
Deploy previewhttps://deploy-preview-48549--material-ui.netlify.app/ Bundle size
Check out the code infra dashboard for more information about this PR. |
ZeeshanTamboli
approved these changes
May 20, 2026
|
Cherry-pick PRs will be created targeting branches: v7.x |
mj12albert
pushed a commit
that referenced
this pull request
May 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #47742.
Instead of computing positioning via a
style: ({ ownerState }) => {...}callback in the styledvariantsarray, this PR:anchorOrigin×overlapconditional logic onto the badge slot's inlinestyle, which sets those CSS variables.Why
variantspurely declarative (plain objects only).Variables
Three CSS variables drive positioning, leveraging existing CSS shorthand:
--Badge-translate—translateX, translateY(comma-separated, for thetranslate()function)--Badge-inset—top right bottom left(space-separated, for theinsetshorthand)--Badge-origin—X Y(space-separated, fortransform-origin)Follows the same "inline-style sets a
--ComponentName-*variable, styled CSS consumes it" pattern already used by:AvatarGroup—--AvatarGroup-spacing(from thespacingprop)Typography—--Typography-textAlign(from thealignprop)TabScrollButton—--TabScrollButton-svgRotate(from RTL + orientation)Behavior
No visible change. Same eight outcomes (top/bottom × left/right × rectangular/circular) produce the same CSS output as before #47742.