Skip to content

Commit 0cf81f3

Browse files
authored
docs(material/icon): add guidance for Material Symbols (#28436)
1 parent 40571e8 commit 0cf81f3

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

src/dev-app/dev-app/dev-app-layout.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {MatSidenavModule} from '@angular/material/sidenav';
1313
import {MatListModule} from '@angular/material/list';
1414
import {MatButtonModule} from '@angular/material/button';
1515
import {RouterModule} from '@angular/router';
16-
import {MatIconModule} from '@angular/material/icon';
16+
import {MatIconModule, MatIconRegistry} from '@angular/material/icon';
1717
import {MatToolbarModule} from '@angular/material/toolbar';
1818
import {MatTooltipModule} from '@angular/material/tooltip';
1919
import {DevAppDirectionality} from './dev-app-directionality';
@@ -110,12 +110,14 @@ export class DevAppLayout {
110110
@Inject(Directionality) private _dir: DevAppDirectionality,
111111
private _changeDetectorRef: ChangeDetectorRef,
112112
@Inject(DOCUMENT) private _document: Document,
113+
private _iconRegistry: MatIconRegistry,
113114
) {
114115
this.toggleTheme(this.state.darkTheme);
115116
this.toggleStrongFocus(this.state.strongFocusEnabled);
116117
this.toggleDensity(Math.max(this._densityScales.indexOf(this.state.density), 0));
117118
this.toggleRippleDisabled(this.state.rippleDisabled);
118119
this.toggleDirection(this.state.direction);
120+
this.toggleM3(this.state.m3Enabled);
119121
}
120122

121123
toggleTheme(value = !this.state.darkTheme) {
@@ -168,9 +170,13 @@ export class DevAppLayout {
168170
(document.getElementById('theme-styles') as HTMLLinkElement).href = value
169171
? 'theme-m3.css'
170172
: 'theme.css';
171-
this.state.m3Enabled = value;
172-
setAppState(this.state);
173173
}
174+
175+
this._iconRegistry.setDefaultFontSetClass(
176+
value ? 'material-symbols-outlined' : 'material-icons',
177+
);
178+
this.state.m3Enabled = value;
179+
setAppState(this.state);
174180
}
175181

176182
getDensityClass() {

src/dev-app/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<link rel="icon" type="image/x-icon" href="favicon.ico">
1010
<link rel="preconnect" href="https://fonts.gstatic.com">
1111
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
12+
<link href="https://fonts.googleapis.com/icon?family=Material+Symbols+Outlined" rel="stylesheet">
1213
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
1314

1415
<!-- FontAwesome for mat-icon demo. -->

src/material/icon/icon.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@ component.
1919
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).
22-
You can specify a different font by setting the `fontSet` input to either the CSS class to apply to
23-
use the desired font, or to an alias previously registered with
24-
`MatIconRegistry.registerFontClassAlias`.
22+
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
25+
CSS class to apply to use the desired font, or to an alias previously registered with
26+
`MatIconRegistry.registerFontClassAlias`. Alternatively you can set the default for all
27+
your application's icons using `MatIconRegistry.setDefaultFontSetClass`.
2528

2629
### Font icons with CSS
2730

0 commit comments

Comments
 (0)