1- # md-icon
2-
31` md-icon ` makes it easier to use _ vector-based_ icons in your app. This directive supports both
42icon fonts and SVG icons, but not bitmap-based formats (png, jpg, etc.).
53
64<!-- example(icon-example) -->
75
8- ## Usage
9-
10- ### Registering new icons
6+ ### Registering icons
117
128` MdIconRegistry ` is an injectable service that allows you to associate icon names with SVG URLs and
139define aliases for CSS font classes. Its methods are discussed below and listed in the API summary.
1410
15- In order to prevent XSS vulnerabilities, any URLs passed to the ` MdIconRegistry ` must be marked as
16- trusted resource URLs by using Angular's ` DomSanitizer ` service.
17-
18- ### Font icons
19-
20- #### Ligatures
11+ ### Font icons with ligatures
2112
2213Some fonts are designed to show icons by using
2314[ ligatures] ( https://en.wikipedia.org/wiki/Typographic_ligature ) , for example by rendering the text
@@ -31,7 +22,7 @@ You can specify a different font by setting the `fontSet` input to either the CS
3122use the desired font, or to an alias previously registered with
3223` MdIconRegistry.registerFontClassAlias ` .
3324
34- #### Font icons via CSS
25+ ### Font icons with CSS
3526
3627Fonts can also display icons by defining a CSS class for each icon glyph, which typically uses a
3728` :before ` selector to cause the icon to appear.
@@ -48,14 +39,17 @@ explicitly set by calling `MdIconRegistry.setDefaultFontSetClass`.
4839When an ` md-icon ` component displays an SVG icon, it does so by directly inlining the SVG content
4940into the page as a child of the component. (Rather than using an <img > tag or a div background
5041image). This makes it easier to apply CSS styles to SVG icons. For example, the default color of the
51- SVG content is the CSS [ currentColor] ( http://www.quirksmode.org/css/color/currentcolor.html ) value.
52- This makes SVG icons by default have the same color as surrounding text, and allows you to change
53- the color by setting the "color" style on the ` md-icon ` element.
42+ SVG content is the CSS
43+ [ currentColor] ( https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#currentColor_keyword )
44+ value. This makes SVG icons by default have the same color as surrounding text, and allows you to
45+ change the color by setting the "color" style on the ` md-icon ` element.
5446
55- #### Icons from URLs
47+ In order to prevent XSS vulnerabilities, any SVG URLs passed to the ` MdIconRegistry ` must be
48+ marked as trusted resource URLs by using Angular's ` DomSanitizer ` service.
5649
57- SVG icons can be used either by directly specifying the icon's URL, or by associating an icon name
58- with a URL and then referring to the name. To use a URL directly, set the ` svgSrc ` input.
50+ Also note that all SVG icons are fetched via XmlHttpRequest, and due to the same-origin policy,
51+ their URLs must be on the same domain as the containing page, or their servers must be configured
52+ to allow cross-domain access.
5953
6054#### Named icons
6155
@@ -78,14 +72,11 @@ as for individually registered icons.
7872Multiple icon sets can be registered in the same namespace. Requesting an icon whose id appears in
7973more than one icon set, the icon from the most recently registered set will be used.
8074
81- Note that all SVG icons are fetched via XmlHttpRequest, and due to the same-origin policy their URLs
82- must be on the same domain as the containing page, or their servers must be configured to allow
83- cross-domain access.
84-
8575### Theming
8676
87- Icons can be themed to match your "primary" palette, your "accent" palette, or your "warn" palette
88- using the ` color ` attribute. Simply pass in the desired palette name.
77+ By default, icons will use the current font color (` currentColor ` ). this color can be changed to
78+ match the current theme's colors using the ` color ` attribute. This can be changed to
79+ ` 'primary' ` , ` 'accent' ` , or ` 'warn' ` .
8980
9081### Accessibility
9182
0 commit comments