Skip to content

Commit d3a50b3

Browse files
devversionjelbourn
authored andcommitted
fix(button): ensure icons are aligned vertically. (#1736)
* The icon buttons are never a perfect circle, because they can shrink (depending on siblings). In Material 1 we solved this by adding `min-width/height`, but having flex-shrink is more appropriate here (it allows developers to easily overwrite height / width) * Sets the line-height for icons only to `i` and `md-icon` elements (as same as for fab buttons) Fixes #1093.
1 parent 13b7dd0 commit d3a50b3

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/lib/button/_button-base.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,16 @@ $md-mini-fab-padding: 8px !default;
8888
@mixin md-fab($size, $padding) {
8989
@extend %md-raised-button;
9090

91+
// Reset the min-width from the button base.
9192
min-width: 0;
93+
9294
border-radius: $md-fab-border-radius;
9395
width: $size;
9496
height: $size;
9597
padding: 0;
9698

99+
flex-shrink: 0;
100+
97101
i, md-icon {
98102
padding: $padding 0;
99103
line-height: $md-icon-button-line-height;

src/lib/button/button.scss

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,26 @@
3535
}
3636

3737
[md-icon-button] {
38-
min-width: 0;
3938
padding: 0;
4039

40+
// Reset the min-width from the button base.
41+
min-width: 0;
42+
4143
width: $md-icon-button-size;
4244
height: $md-icon-button-size;
4345

44-
line-height: $md-icon-button-line-height;
46+
flex-shrink: 0;
47+
48+
line-height: $md-icon-button-size;
4549
border-radius: $md-icon-button-border-radius;
4650

47-
.md-button-wrapper > * {
51+
i, md-icon {
4852
line-height: $md-icon-button-line-height;
49-
vertical-align: middle;
5053
}
5154
}
5255

5356
// The text and icon should be vertical aligned inside a button
54-
[md-button], [md-raised-button] {
57+
[md-button], [md-raised-button], [md-icon-button] {
5558
.md-button-wrapper > * {
5659
vertical-align: middle;
5760
}

0 commit comments

Comments
 (0)