Skip to content

Commit ab48d37

Browse files
committed
docs(icon): add note about HttpClientModule requirement
Adds a note to the icon docs that the `HttpClientModule` needs to be included. Also does some minor cleanup in the overview doc.
1 parent 09dc459 commit ab48d37

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/material/icon/icon.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,21 @@ explicitly set by calling `MatIconRegistry.setDefaultFontSetClass`.
3838
### SVG icons
3939

4040
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
41+
into the page as a child of the component. (Rather than using an `<img>` tag or a `div` background
4242
image). This makes it easier to apply CSS styles to SVG icons. For example, the default color of the
4343
SVG content is the CSS
4444
[currentColor](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#currentColor_keyword)
4545
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.
4747

4848
In order to prevent XSS vulnerabilities, any SVG URLs and HTML strings passed to the
4949
`MatIconRegistry` must be marked as trusted by using Angular's `DomSanitizer` service.
5050

51-
Also note that all SVG icons, registered by URL, are fetched via XmlHttpRequest, and due to the
51+
To fetch remote SVG icons, the `MatIconRegistry` uses Angular's `HttpClient` service. If you haven't
52+
included the [`HttpClientModule` from the `@angular/common/http` package](https://angular.io/guide/http)
53+
in your module's `imports`, you will get an error at runtime.
54+
55+
Note that all SVG icons, registered by URL, are fetched via XmlHttpRequest, and due to the
5256
same-origin policy, their URLs must be on the same domain as the containing page, or their servers
5357
must be configured to allow cross-domain access.
5458

@@ -107,8 +111,8 @@ some icon on the page, a more appropriate element should "own" the interaction:
107111
direct text content, `aria-label`, or `aria-labelledby`.
108112

109113
#### 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
114+
When the presence of an icon communicates some information to the user whether as an indicator or
115+
by being inlined into a block of text, that information must also be made available to
112116
screen-readers. The most straightforward way to do this is to
113117
1. Add a `<span>` as an adjacent sibling to the `<mat-icon>` element with text that conveys the same
114118
information as the icon.
@@ -118,7 +122,7 @@ on-screen but still available to screen-reader users.
118122
### Bidirectionality
119123

120124
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
125+
to be [mirrored for RTL users](https://material.io/design/usability/bidirectionality.html). If
122126
you want to mirror an icon only in an RTL layout, you can use the `mat-icon-rtl-mirror` CSS class.
123127

124128
```html

0 commit comments

Comments
 (0)