Skip to content

Commit 5d03c1a

Browse files
crisbetoandrewseguin
authored andcommitted
fix(chips): wrong margin on single chip (#4366)
* Fixes single chips having a left margin. * Reduces the amount of CSS used to set up the chip margins. Fixes #4359.
1 parent 1fd50aa commit 5d03c1a

File tree

1 file changed

+9
-38
lines changed

1 file changed

+9
-38
lines changed

src/lib/chips/chips.scss

Lines changed: 9 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,48 +6,10 @@ $mat-chip-line-height: 16px;
66
$mat-chips-chip-margin: $mat-chip-horizontal-padding / 4;
77

88
.mat-chip-list-wrapper {
9-
109
display: flex;
1110
flex-direction: row;
1211
flex-wrap: wrap;
1312
align-items: flex-start;
14-
15-
/*
16-
* Only apply the margins to chips
17-
*/
18-
.mat-chip:not(.mat-basic-chip) {
19-
margin: 0 $mat-chips-chip-margin 0 $mat-chips-chip-margin;
20-
21-
// Remove the margin from the first element (in both LTR and RTL)
22-
&:first-child {
23-
margin: {
24-
left: 0;
25-
right: $mat-chips-chip-margin;
26-
}
27-
28-
[dir='rtl'] & {
29-
margin: {
30-
left: $mat-chips-chip-margin;
31-
right: 0;
32-
}
33-
}
34-
}
35-
36-
// Remove the margin from the last element (in both LTR and RTL)
37-
&:last-child {
38-
margin: {
39-
left: $mat-chips-chip-margin;
40-
right: 0;
41-
}
42-
43-
[dir='rtl'] & {
44-
margin: {
45-
left: 0;
46-
right: $mat-chips-chip-margin;
47-
}
48-
}
49-
}
50-
}
5113
}
5214

5315
.mat-chip:not(.mat-basic-chip) {
@@ -57,6 +19,15 @@ $mat-chips-chip-margin: $mat-chip-horizontal-padding / 4;
5719

5820
font-size: $mat-chip-font-size;
5921
line-height: $mat-chip-line-height;
22+
23+
// Apply a margin to adjacent sibling chips.
24+
& + & {
25+
margin: 0 0 0 $mat-chips-chip-margin;
26+
27+
[dir='rtl'] & {
28+
margin: 0 $mat-chips-chip-margin 0 0;
29+
}
30+
}
6031
}
6132

6233
.mat-chip-list-stacked .mat-chip-list-wrapper {

0 commit comments

Comments
 (0)