File tree Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 32
32
Custom icon font and CSS:
33
33
< mat-icon fontSet ="fontawesome " fontIcon ="fa-birthday-cake "> </ mat-icon >
34
34
</ p >
35
+
36
+ < p >
37
+ Inline styling < mat-icon inline ="true "> favorite</ mat-icon > icons appear as
38
+ the same < mat-icon inline ="true "> directions_car</ mat-icon > size as text around them.</ p >
35
39
</ div >
Original file line number Diff line number Diff line change @@ -10,6 +10,13 @@ $mat-icon-size: 24px !default;
10
10
fill : currentColor ;
11
11
height : $mat-icon-size ;
12
12
width : $mat-icon-size ;
13
+
14
+ & .mat-icon-inline {
15
+ font-size : inherit ;
16
+ height : inherit ;
17
+ line-height : inherit ;
18
+ width : inherit ;
19
+ }
13
20
}
14
21
15
22
.mat-form-field :not (.mat-form-field-appearance-legacy ) {
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import {
19
19
ViewEncapsulation ,
20
20
} from '@angular/core' ;
21
21
import { CanColor , mixinColor } from '@angular/material/core' ;
22
+ import { coerceBooleanProperty } from '@angular/cdk/coercion' ;
22
23
import { MatIconRegistry } from './icon-registry' ;
23
24
24
25
@@ -67,13 +68,25 @@ export const _MatIconMixinBase = mixinColor(MatIconBase);
67
68
host : {
68
69
'role' : 'img' ,
69
70
'class' : 'mat-icon' ,
71
+ '[class.mat-icon-inline]' : 'inline' ,
70
72
} ,
71
73
encapsulation : ViewEncapsulation . None ,
72
74
preserveWhitespaces : false ,
73
75
changeDetection : ChangeDetectionStrategy . OnPush ,
74
76
} )
75
77
export class MatIcon extends _MatIconMixinBase implements OnChanges , OnInit , CanColor {
76
78
79
+ /** Whether the icon should be inline. */
80
+ @Input ( )
81
+ get inline ( ) : boolean {
82
+ return this . _inline ;
83
+ }
84
+ set inline ( inline : boolean ) {
85
+ this . _inline = coerceBooleanProperty ( inline ) ;
86
+ }
87
+ private _inline : boolean = false ;
88
+
89
+
77
90
/** Name of the icon in the SVG icon set. */
78
91
@Input ( ) svgIcon : string ;
79
92
You can’t perform that action at this time.
0 commit comments