Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Button text is not vertically aligned #13926

Closed
adipascu opened this issue Dec 17, 2018 · 10 comments
Closed

Button text is not vertically aligned #13926

adipascu opened this issue Dec 17, 2018 · 10 comments
Labels
bug 🐛 Something doesn't work component: button This is the name of the generic UI component, not the React module! good first issue Great for first contributions. Enable to learn the contribution process.

Comments

@adipascu
Copy link
Contributor

adipascu commented Dec 17, 2018

I feel like the buttons in material ui v3.6.2 do not have the text vertically aligned while rendering on Chrome 70.

I think that that they looked fine in material-ui v0.x but in the recent material-ui versions they are a bit taller and have a "chin" under the text.

Here are some screenshots from the docs:

v0.x v3.6.2
screen shot 2018-12-17 at 21 16 00 screen shot 2018-12-17 at 21 12 04
DOM link DOM link
@oliviertassinari oliviertassinari added good first issue Great for first contributions. Enable to learn the contribution process. component: button This is the name of the generic UI component, not the React module! bug 🐛 Something doesn't work labels Dec 17, 2018
@oliviertassinari
Copy link
Member

@adipascu Yes, you are right, the height of the button component is wrong 😱:

capture d ecran 2018-12-17 a 23 53 30

It should be 36px over 37px. I propose the following fix:

export const styles = theme => ({
  /* Styles applied to the root element. */
  root: {
    ...theme.typography.button,
    boxSizing: 'border-box',
    minWidth: 64,
    minHeight: 36,
-   padding: '8px 16px',
+   padding: '6px 16px',

https://github.com/mui-org/material-ui/blob/dc396ad3d13224412105e86be43ddb607f8a543d/packages/material-ui/src/Button/Button.js#L20

What do you think about it? Do you want to work on it? :)

@adipascu
Copy link
Contributor Author

adipascu commented Dec 17, 2018

My first comment had screenshots at 200% zoom, the issue is more accentuated at normal 100% zoom, this might be also a Chrome renderer issue.

@oliviertassinari woah, that fixes it for me, I posted a PR.

oliviertassinari pushed a commit that referenced this issue Dec 25, 2018
* Fix text alignment by reducing button height

Fix #13926

* a second try
@sandro768
Copy link

I've got the same issue. in material UI ^4.9.12 version
Duplicate of #13926 #

@ethoman
Copy link

ethoman commented Sep 24, 2020

Likewise, the padding is still messed up - on chrome it is centered, on safari the padding is wrong and the button text is not centered - this issue only occurs if you specify button height in styles

@oliviertassinari
Copy link
Member

@ethoman One of the issues with vertical alignment of the text in a button is that different fonts have different centering.
For instance, in https://seek-oss.github.io/capsize/ you can see that Inter is better centered than Roboto.

@ericettensohn
Copy link

This is a weird one - I see this issue at 100% zoom in chrome, but as soon as I zoom in further, it disappears and the text is vertically centered again. I opened screenshots up in Photoshop to double check, and sure enough the 100% zoom level button has 1-2 more pixels of space below the text than it does above.

@CyanoFresh
Copy link
Contributor

have this problem on mui 5.6

@dkurucz
Copy link

dkurucz commented May 2, 2022

Also seeing this problem on MUI 5.6.2. This issue is made especially obvious when a start or end icon is added alongside the text using the Button properties. If it helps, I was able to solve this specific outlying issue by wrapping the button text in a Box and setting the height of the Box to the height of the properly sized icon, and that allowed everything to line up, but this is far from an ideal solution.

@n-ii-ma
Copy link

n-ii-ma commented May 7, 2022

I'm also experiencing this issue on MUI 5.6.4.

@malikarami
Copy link

malikarami commented Jun 12, 2022

I am experiencing this issue too(with the IconButton). The Mui version is 5.8.2
As you can see the SVG icon is centered but the text is not. I have tried setting flex alignment and justification attributes, but they did not help.

<IconButton size="large"> <AddIcon /> button text </IconButton>

Screen Shot 2022-06-12 at 21 10 07
Screen Shot 2022-06-12 at 21 10 18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: button This is the name of the generic UI component, not the React module! good first issue Great for first contributions. Enable to learn the contribution process.
Projects
None yet
Development

No branches or pull requests

9 participants