Skip to content

Commit f615161

Browse files
authored
docs(material/icon): Update docs and examples (#29260)
1 parent af141db commit f615161

File tree

5 files changed

+22
-13
lines changed

5 files changed

+22
-13
lines changed

src/components-examples/material/icon/icon-harness/icon-harness-example.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component} from '@angular/core';
1+
import {ChangeDetectionStrategy, Component} from '@angular/core';
22
import {MatIconModule} from '@angular/material/icon';
33

44
/**
@@ -9,5 +9,6 @@ import {MatIconModule} from '@angular/material/icon';
99
templateUrl: 'icon-harness-example.html',
1010
standalone: true,
1111
imports: [MatIconModule],
12+
changeDetection: ChangeDetectionStrategy.OnPush,
1213
})
1314
export class IconHarnessExample {}

src/components-examples/material/icon/icon-overview/icon-overview-example.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component} from '@angular/core';
1+
import {ChangeDetectionStrategy, Component} from '@angular/core';
22
import {MatIconModule} from '@angular/material/icon';
33

44
/**
@@ -9,5 +9,6 @@ import {MatIconModule} from '@angular/material/icon';
99
templateUrl: 'icon-overview-example.html',
1010
standalone: true,
1111
imports: [MatIconModule],
12+
changeDetection: ChangeDetectionStrategy.OnPush,
1213
})
1314
export class IconOverviewExample {}

src/components-examples/material/icon/icon-svg/icon-svg-example.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component} from '@angular/core';
1+
import {ChangeDetectionStrategy, Component} from '@angular/core';
22
import {DomSanitizer} from '@angular/platform-browser';
33
import {MatIconRegistry, MatIconModule} from '@angular/material/icon';
44

@@ -20,6 +20,7 @@ const THUMBUP_ICON =
2020
templateUrl: 'icon-svg-example.html',
2121
standalone: true,
2222
imports: [MatIconModule],
23+
changeDetection: ChangeDetectionStrategy.OnPush,
2324
})
2425
export class IconSvgExample {
2526
constructor(iconRegistry: MatIconRegistry, sanitizer: DomSanitizer) {

src/material/icon/icon.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ By default, `<mat-icon>` expects the
2020
[Material icons font](https://google.github.io/material-design-icons/#icon-font-for-the-web).
2121
(You will still need to include the HTML to load the font and its CSS, as described in the link).
2222

23-
You can specify a different font, such as Material's latest icons,
24-
[Material Symbols](https://fonts.google.com/icons), by setting the `fontSet` input to either the
23+
You can specify a different font, such as Material's latest icons,
24+
[Material Symbols](https://fonts.google.com/icons), by setting the `fontSet` input to either the
2525
CSS class to apply to use the desired font, or to an alias previously registered with
2626
`MatIconRegistry.registerFontClassAlias`. Alternatively you can set the default for all
2727
your application's icons using `MatIconRegistry.setDefaultFontSetClass`.
@@ -83,12 +83,6 @@ as for individually registered icons.
8383
Multiple icon sets can be registered in the same namespace. Requesting an icon whose id appears in
8484
more than one icon set, the icon from the most recently registered set will be used.
8585

86-
### Theming
87-
88-
By default, icons will use the current font color (`currentColor`). this color can be changed to
89-
match the current theme's colors using the `color` attribute. This can be changed to
90-
`'primary'`, `'accent'`, or `'warn'`.
91-
9286
### Accessibility
9387

9488
Similar to an `<img>` element, an icon alone does not convey any useful information for a

src/material/icon/icon.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,13 @@ import {MatIconRegistry} from './icon-registry';
3232

3333
/** Default options for `mat-icon`. */
3434
export interface MatIconDefaultOptions {
35-
/** Default color of the icon. */
35+
/**
36+
* Theme color of the icon. This API is supported in M2 themes only, it
37+
* has no effect in M3 themes.
38+
*
39+
* For information on applying color variants in M3, see
40+
* https://material.angular.io/guide/theming#using-component-color-variants.
41+
*/
3642
color?: ThemePalette;
3743
/** Font set that the icon is a part of. */
3844
fontSet?: string;
@@ -150,7 +156,13 @@ const funcIriPattern = /^url\(['"]?#(.*?)['"]?\)$/;
150156
export class MatIcon implements OnInit, AfterViewChecked, OnDestroy {
151157
private _defaultColor: ThemePalette;
152158

153-
/** Theme palette color of the icon. */
159+
/**
160+
* Theme color of the icon. This API is supported in M2 themes only, it
161+
* has no effect in M3 themes.
162+
*
163+
* For information on applying color variants in M3, see
164+
* https://material.angular.io/guide/theming#using-component-color-variants.
165+
*/
154166
@Input()
155167
get color() {
156168
return this._color || this._defaultColor;

0 commit comments

Comments
 (0)