@@ -37,20 +37,25 @@ explicitly set by calling `MatIconRegistry.setDefaultFontSetClass`.
37
37
38
38
### SVG icons
39
39
40
- When an ` mat-icon ` component displays an SVG icon, it does so by directly inlining the SVG content
41
- into the page as a child of the component. (Rather than using an ` <img> ` tag or a div background
42
- image). This makes it easier to apply CSS styles to SVG icons . For example, the default color of the
40
+ ` < mat-icon> ` displays SVG icons by directly inlining the SVG content into the DOM
41
+ as a child of itself. This approach offers an advantage over an ` <img> ` tag or a CSS
42
+ ` background- image` because it allows styling the SVG with CSS . For example, the default color of the
43
43
SVG content is the CSS
44
44
[ currentColor] ( https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#currentColor_keyword )
45
45
value. This makes SVG icons by default have the same color as surrounding text, and allows you to
46
- change the color by setting the " color" style on the ` mat-icon ` element.
46
+ change the color by setting the ` color ` style on the ` mat-icon ` element.
47
47
48
- In order to prevent XSS vulnerabilities, any SVG URLs and HTML strings passed to the
48
+ In order to guard against XSS vulnerabilities, any SVG URLs and HTML strings passed to the
49
49
` MatIconRegistry ` must be marked as trusted by using Angular's ` DomSanitizer ` service.
50
50
51
- Also note that all SVG icons, registered by URL, are fetched via XmlHttpRequest, and due to the
52
- same-origin policy, their URLs must be on the same domain as the containing page, or their servers
53
- must be configured to allow cross-domain access.
51
+ ` MatIconRegistry ` fetches all remote SVG icons via Angular's ` HttpClient ` service. If you haven't
52
+ included [ ` HttpClientModule ` from the ` @angular/common/http ` package] ( https://angular.io/guide/http )
53
+ in your ` NgModule ` imports, you will get an error at runtime.
54
+
55
+ Note that ` HttpClient ` fetches SVG icons registered with a URL via ` XmlHttpRequest ` , subject to the
56
+ [ Same-origin policy] ( https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy ) . This
57
+ means that icon URLs must have the same origin as the containing page or that the application's
58
+ server must be configured to allow cross-origin requests.
54
59
55
60
#### Named icons
56
61
@@ -92,8 +97,8 @@ element.
92
97
In thinking about accessibility, it is useful to place icon use into one of three categories:
93
98
1 . ** Decorative** : the icon conveys no real semantic meaning and is purely cosmetic.
94
99
2 . ** Interactive** : a user will click or otherwise interact with the icon to perform some action.
95
- 3 . ** Indicator** : the icon is not interactive, but it conveys some information, such as a status. This
96
- includes using the icon in place of text inside of a larger message.
100
+ 3 . ** Indicator** : the icon is not interactive, but it conveys some information, such as a status.
101
+ This includes using the icon in place of text inside of a larger message.
97
102
98
103
#### Decorative icons
99
104
When the icon is purely cosmetic and conveys no real semantic meaning, the ` <mat-icon> ` element
@@ -107,8 +112,8 @@ some icon on the page, a more appropriate element should "own" the interaction:
107
112
direct text content, ` aria-label ` , or ` aria-labelledby ` .
108
113
109
114
#### Indicator icons
110
- When the presence of an icon communicates some information to the user whether as an indicator or
111
- by being inlined into a block of text, that information must also be made available to
115
+ When the presence of an icon communicates some information to the user whether as an indicator or
116
+ by being inlined into a block of text, that information must also be made available to
112
117
screen-readers. The most straightforward way to do this is to
113
118
1 . Add a ` <span> ` as an adjacent sibling to the ` <mat-icon> ` element with text that conveys the same
114
119
information as the icon.
@@ -118,7 +123,7 @@ on-screen but still available to screen-reader users.
118
123
### Bidirectionality
119
124
120
125
By default icons in an RTL layout will look exactly the same as in LTR, however certain icons have
121
- to be [ mirrored for RTL users] ( https://material.io/guidelines /usability/bidirectionality.html ) . If
126
+ to be [ mirrored for RTL users] ( https://material.io/design /usability/bidirectionality.html ) . If
122
127
you want to mirror an icon only in an RTL layout, you can use the ` mat-icon-rtl-mirror ` CSS class.
123
128
124
129
``` html
0 commit comments