Icons inside mat-icon-button not vertically centered.
See original GitHub issueBug, feature request, or proposal:
Bug
What is the expected behavior?
Icons inside mat-icon-button should be perfectly vertically centered.
What is the current behavior?
A 24px icon inside a 40px mat-icon-button by default ends up with 9px top padding and 7px top padding due to baseline-driven CSS layout.
Screenshot (red outlines and highlight to demonstrate the problem):
What are the steps to reproduce?
Any basic mat-icon-button example has this problem, but I’ve forked and simplified an official example to make it easier to see: https://stackblitz.com/edit/angular-3mdmnc
Is there anything else we should know?
This is one possible fix:
/* Coerce the <span> icon container away from display:inline */
.mat-icon-button .mat-button-wrapper {
display: flex;
justify-content: center;
}
Issue Analytics
- State:
- Created 6 years ago
- Reactions:103
- Comments:21 (8 by maintainers)
Top Results From Across the Web
mat-icon does not center in mat-button - Stack Overflow
When I make the font bigger the mat-icon is no longer centered. how can I center the icon inside of the button vertically...
Read more >Angular Material Menu: mat Menu example
To implement menu items in Angular we can use angular material menu module called MatMenuModule.
Read more >Adding a responsive Angular Material toolbar to your website
How to add a responsive Angular Material toolbar to the top of your website.
Read more >List | Angular Material
List items that have more than one line of text have to use the matListItemTitle directive to indicate their title text for accessibility...
Read more >concept toolbar in category angular - liveBook · Manning
The button should contain an icon with three vertical dots (see figure 5.14), and the directive mat-icon-button turns a regular button into a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Any news on this? It’s been an issue for well over a year now.
The way I do it is to utilize the
inline
attribute. This will cause the icon to correctly scale with the size of the button.I add this to my
styles.css
to: