Skip to content

Commit f042068

Browse files
crisbetoandrewseguin
authored andcommitted
fix(badge): remove badge margins (#11599)
Removes the margins that are being added to an element that has a badge. Having the margin was problematic, because it can influence the user's layout and it doesn't handle toggling between a visible and hidden badge very well. Fixes #11596.
1 parent 8842fb2 commit f042068

File tree

2 files changed

+9
-20
lines changed

2 files changed

+9
-20
lines changed

src/demo-app/badge/badge-demo.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
11
.demo-badge {
22
margin-bottom: 25px;
33
}
4+
5+
.mat-badge {
6+
margin-right: 22px;
7+
8+
[dir='rtl'] & {
9+
margin-right: 0;
10+
margin-left: 22px;
11+
}
12+
}

src/lib/badge/_badge-theme.scss

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,35 +38,25 @@ $mat-badge-large-size: $mat-badge-default-size + 6;
3838
}
3939

4040
&.mat-badge-before {
41-
margin-left: $size;
42-
4341
.mat-badge-content {
4442
left: -$size;
4543
}
4644
}
4745

4846
[dir='rtl'] &.mat-badge-before {
49-
margin-left: 0;
50-
margin-right: $size;
51-
5247
.mat-badge-content {
5348
left: auto;
5449
right: -$size;
5550
}
5651
}
5752

5853
&.mat-badge-after {
59-
margin-right: $size;
60-
6154
.mat-badge-content {
6255
right: -$size;
6356
}
6457
}
6558

6659
[dir='rtl'] &.mat-badge-after {
67-
margin-right: 0;
68-
margin-left: $size;
69-
7060
.mat-badge-content {
7161
right: auto;
7262
left: -$size;
@@ -75,35 +65,25 @@ $mat-badge-large-size: $mat-badge-default-size + 6;
7565

7666
&.mat-badge-overlap {
7767
&.mat-badge-before {
78-
margin-left: $size / 2;
79-
8068
.mat-badge-content {
8169
left: -$size / 2;
8270
}
8371
}
8472

8573
[dir='rtl'] &.mat-badge-before {
86-
margin-left: 0;
87-
margin-right: $size / 2;
88-
8974
.mat-badge-content {
9075
left: auto;
9176
right: -$size / 2;
9277
}
9378
}
9479

9580
&.mat-badge-after {
96-
margin-right: $size / 2;
97-
9881
.mat-badge-content {
9982
right: -$size / 2;
10083
}
10184
}
10285

10386
[dir='rtl'] &.mat-badge-after {
104-
margin-right: 0;
105-
margin-left: $size;
106-
10787
.mat-badge-content {
10888
right: auto;
10989
left: -$size / 2;

0 commit comments

Comments
 (0)