Skip to content

Commit

Permalink
docs(material/icon): Update docs and examples (#29260)
Browse files Browse the repository at this point in the history
  • Loading branch information
amysorto authored Jun 17, 2024
1 parent af141db commit f615161
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component} from '@angular/core';
import {ChangeDetectionStrategy, Component} from '@angular/core';
import {MatIconModule} from '@angular/material/icon';

/**
Expand All @@ -9,5 +9,6 @@ import {MatIconModule} from '@angular/material/icon';
templateUrl: 'icon-harness-example.html',
standalone: true,
imports: [MatIconModule],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class IconHarnessExample {}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component} from '@angular/core';
import {ChangeDetectionStrategy, Component} from '@angular/core';
import {MatIconModule} from '@angular/material/icon';

/**
Expand All @@ -9,5 +9,6 @@ import {MatIconModule} from '@angular/material/icon';
templateUrl: 'icon-overview-example.html',
standalone: true,
imports: [MatIconModule],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class IconOverviewExample {}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component} from '@angular/core';
import {ChangeDetectionStrategy, Component} from '@angular/core';
import {DomSanitizer} from '@angular/platform-browser';
import {MatIconRegistry, MatIconModule} from '@angular/material/icon';

Expand All @@ -20,6 +20,7 @@ const THUMBUP_ICON =
templateUrl: 'icon-svg-example.html',
standalone: true,
imports: [MatIconModule],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class IconSvgExample {
constructor(iconRegistry: MatIconRegistry, sanitizer: DomSanitizer) {
Expand Down
10 changes: 2 additions & 8 deletions src/material/icon/icon.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ By default, `<mat-icon>` expects the
[Material icons font](https://google.github.io/material-design-icons/#icon-font-for-the-web).
(You will still need to include the HTML to load the font and its CSS, as described in the link).

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

### Theming

By default, icons will use the current font color (`currentColor`). this color can be changed to
match the current theme's colors using the `color` attribute. This can be changed to
`'primary'`, `'accent'`, or `'warn'`.

### Accessibility

Similar to an `<img>` element, an icon alone does not convey any useful information for a
Expand Down
16 changes: 14 additions & 2 deletions src/material/icon/icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ import {MatIconRegistry} from './icon-registry';

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

/** Theme palette color of the icon. */
/**
* Theme color of the icon. This API is supported in M2 themes only, it
* has no effect in M3 themes.
*
* For information on applying color variants in M3, see
* https://material.angular.io/guide/theming#using-component-color-variants.
*/
@Input()
get color() {
return this._color || this._defaultColor;
Expand Down

0 comments on commit f615161

Please sign in to comment.