material-web icon indicating copy to clipboard operation
material-web copied to clipboard

[mwc-button] Icon is not vertically aligned with the button text

Open contis2908 opened this issue 3 years ago • 3 comments

Describe the bug Displaying a button containing an icon and text will not show them both vertically aligned.

To Reproduce Steps to reproduce the behavior: Implement mwc-button with property icon and label

Expected behavior Text and icon should be automatically alligned.

Screenshots Screenshot 2021-11-03 at 12 13 50

Browser Version (please complete the following information):

  • OS: macOS Big Sur
  • Browser: tested in chrome
  • Version: Version 95.0.4638.54 (Official Build) (x86_64)

Additional context The problem can be fixed if the span container with class leading-icon (that holds the slotted icon) css display is set to display: contents;

contis2908 avatar Nov 03 '21 11:11 contis2908

Ah, the span's line-height is larger than the icon's. Good catch!

dfreedm avatar Nov 03 '21 22:11 dfreedm

Yes, then line-height inheritance is a problem. However, I believe that this isn't enough depending on the expected outcome. I would expect the text and icon to be aligned in the center. Fixing the line-height will position them just on their baseline. While this is fine I believe that depending on the icon in many situations this will give a weird look to the button. Screenshot 2021-11-04 at 11 07 10 Screenshot 2021-11-04 at 11 07 24

contis2908 avatar Nov 04 '21 10:11 contis2908

in many situations this will give a weird look to the button.

Like, possibly related: #1045, #2131.

christophe-g avatar Nov 04 '21 10:11 christophe-g

Fixed in M3

asyncLiz avatar Aug 02 '23 02:08 asyncLiz