Skip to content

Commit 4c02ee4

Browse files
authored
fix: restore icon centering after MUI v9 upgrade (#12440)
MUI v5's Box converted the system prop fontSize={0} to font-size: 0, zeroing the strut so the svg child filled the icon span. Since the v9 upgrade (52d5bce) Box only styles through sx, so the prop was passed through as a dead font-size="0" DOM attribute and every s:true icon (svg child path) drifted down a few px inside text-sized containers (e.g. MaskBlue size={16} in the ProfileCard avatar badge). Move fontSize: 0 into the sx base style (restoring v5 semantics), add lineHeight: 0 to guard against host pages inheriting an absolute line-height, and drop the dead prop.
1 parent f5be376 commit 4c02ee4

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

packages/icons/utils/internal.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ export function __createIcon(name, variants, intrinsicSize = [24, 24]) {
3333
)
3434
const base = {
3535
display: 'inline-block',
36+
// To align icon center: zero out the strut so the svg child fills the span.
37+
fontSize: 0,
38+
lineHeight: 0,
3639
backgroundRepeat: 'no-repeat',
3740
backgroundPosition: 'center',
3841
flexShrink: 0,
@@ -56,8 +59,6 @@ export function __createIcon(name, variants, intrinsicSize = [24, 24]) {
5659
ref,
5760
'data-icon': name,
5861
sx: Array.isArray(sx) ? [iconStyle, ...sx] : [iconStyle, sx],
59-
// To align icon center.
60-
fontSize: 0,
6162
}
6263
// background image can't be correctly resolved on Firefly in ShadowDOM.
6364
// This is a workaround.

0 commit comments

Comments
 (0)