Skip to content

Commit b23e321

Browse files
asyncLizcopybara-github
authored andcommitted
fix(icon): fix uncentered icons when using WCAG text spacing overrides
If you were using `font-size`, you may need to change it to `--md-icon-size` if icons shift. PiperOrigin-RevId: 607096212
1 parent 8d2b644 commit b23e321

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

icon/internal/_icon.scss

+10
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,24 @@
4040
font-family: map.get($tokens, 'font');
4141
display: inline-flex;
4242
font-style: normal;
43+
place-items: center;
44+
place-content: center;
4345
line-height: 1;
4446
// Avoid displaying overflowing text if font ligatures have not loaded.
4547
overflow: hidden;
48+
// Changing the letter-spacing for WCAG text spacing compliance will shift
49+
// around font ligature icons, so we revert that to normal. Note: some a11y
50+
// tools use `!important` style injection and may see shifting icons. Actual
51+
// text spacing override implementations in projects should not set
52+
// `letter-spacing` on icons, or revert it with a `text-indent` of the same
53+
// size.
4654
letter-spacing: normal;
4755
text-transform: none;
4856
user-select: none;
4957
white-space: nowrap;
5058
word-wrap: normal;
59+
// Prevent icons from shrinking when placed in a flex container.
60+
flex-shrink: 0;
5161

5262
/* Support for all WebKit browsers. */
5363
-webkit-font-smoothing: antialiased;

0 commit comments

Comments
 (0)