Skip to content

Commit 3cc9c67

Browse files
crisbetommalerba
authored andcommitted
feat(chips): align with 2018 material design spec (#12838)
Aligns the chips with the latest Material Design spec. Includes adding a new hover state.
1 parent 95acccc commit 3cc9c67

File tree

2 files changed

+37
-12
lines changed

2 files changed

+37
-12
lines changed

src/lib/chips/_chips-theme.scss

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
@import '../core/theming/theming';
44
@import '../core/typography/typography-utils';
55

6-
// TODO(crisbeto): these values don't correspond to any of the typography breakpoints.
7-
$mat-chip-font-size: 13px;
8-
$mat-chip-line-height: 18px;
96
$mat-chip-remove-font-size: 18px;
107

118
@mixin mat-chips-theme-color($color) {
@@ -64,8 +61,8 @@ $mat-chip-remove-font-size: 18px;
6461

6562
@mixin mat-chips-typography($config) {
6663
.mat-chip {
67-
font-size: $mat-chip-font-size;
68-
line-height: $mat-chip-line-height;
64+
font-size: mat-font-size($config, body-2);
65+
font-weight: mat-font-weight($config, body-2);
6966

7067
.mat-chip-trailing-icon.mat-icon,
7168
.mat-chip-remove.mat-icon {

src/lib/chips/chips.scss

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
1+
@import '../core/style/variables';
12
@import '../core/style/elevation';
3+
@import '../core/style/layout-common';
24
@import '../../cdk/a11y/a11y';
35

6+
$mat-chip-min-height: 32px;
47
$mat-chip-vertical-padding: 7px;
58
$mat-chip-horizontal-padding: 12px;
69

710
$mat-chip-remove-vertical-padding: 7px;
8-
$mat-chip-remove-before-margin: 7px;
9-
$mat-chip-remove-after-padding: 7px;
11+
$mat-chip-remove-before-margin: 8px;
12+
$mat-chip-remove-after-padding: 8px;
1013

1114
$mat-chip-avatar-vertical-padding: 0;
1215
$mat-chip-avatar-before-padding: 0;
16+
$mat-chip-avatar-before-margin: 4px;
1317
$mat-chip-avatar-after-margin: 8px;
1418

1519
$mat-chips-chip-margin: 4px;
1620

1721
$mat-chip-input-width: 150px;
18-
$mat-chip-input-margin: 3px;
22+
$mat-chip-input-margin: 4px;
1923

20-
$mat-chip-avatar-size: 32px;
24+
$mat-chip-avatar-size: 24px;
2125
$mat-chip-remove-size: 18px;
2226

2327
.mat-chip {
@@ -31,17 +35,41 @@ $mat-chip-remove-size: 18px;
3135
@include mat-elevation-transition;
3236
display: inline-flex;
3337
padding: $mat-chip-vertical-padding $mat-chip-horizontal-padding;
34-
border-radius: $mat-chip-horizontal-padding * 2;
38+
border-radius: 16px;
3539
align-items: center;
3640
cursor: default;
41+
min-height: $mat-chip-min-height;
3742

3843
.mat-chip-remove.mat-icon {
3944
width: $mat-chip-remove-size;
4045
height: $mat-chip-remove-size;
4146
}
4247

48+
// Overlay used to darken the chip on hover and focus.
49+
&::after {
50+
@include mat-fill;
51+
border-radius: inherit;
52+
background-color: black;
53+
opacity: 0;
54+
content: '';
55+
pointer-events: none;
56+
transition: opacity 200ms $swift-ease-in-out-timing-function;
57+
}
58+
59+
&:hover::after {
60+
opacity: 0.12;
61+
}
62+
4363
&:focus {
4464
outline: none;
65+
66+
&::after {
67+
opacity: 0.16;
68+
}
69+
}
70+
71+
&:active {
72+
@include mat-elevation(3);
4573
}
4674

4775
@include cdk-high-contrast {
@@ -95,11 +123,11 @@ $mat-chip-remove-size: 18px;
95123
width: $mat-chip-avatar-size;
96124
height: $mat-chip-avatar-size;
97125
margin-right: $mat-chip-avatar-after-margin;
98-
margin-left: 0;
126+
margin-left: $mat-chip-avatar-before-margin;
99127

100128
[dir='rtl'] & {
101129
margin-left: $mat-chip-avatar-after-margin;
102-
margin-right: 0;
130+
margin-right: $mat-chip-avatar-before-margin;
103131
}
104132
}
105133

0 commit comments

Comments
 (0)