Skip to content

Commit

Permalink
docs(material/icon): add guidance for Material Symbols (#28436)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewseguin authored Jan 22, 2024
1 parent 40571e8 commit 0cf81f3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
12 changes: 9 additions & 3 deletions src/dev-app/dev-app/dev-app-layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {MatSidenavModule} from '@angular/material/sidenav';
import {MatListModule} from '@angular/material/list';
import {MatButtonModule} from '@angular/material/button';
import {RouterModule} from '@angular/router';
import {MatIconModule} from '@angular/material/icon';
import {MatIconModule, MatIconRegistry} from '@angular/material/icon';
import {MatToolbarModule} from '@angular/material/toolbar';
import {MatTooltipModule} from '@angular/material/tooltip';
import {DevAppDirectionality} from './dev-app-directionality';
Expand Down Expand Up @@ -110,12 +110,14 @@ export class DevAppLayout {
@Inject(Directionality) private _dir: DevAppDirectionality,
private _changeDetectorRef: ChangeDetectorRef,
@Inject(DOCUMENT) private _document: Document,
private _iconRegistry: MatIconRegistry,
) {
this.toggleTheme(this.state.darkTheme);
this.toggleStrongFocus(this.state.strongFocusEnabled);
this.toggleDensity(Math.max(this._densityScales.indexOf(this.state.density), 0));
this.toggleRippleDisabled(this.state.rippleDisabled);
this.toggleDirection(this.state.direction);
this.toggleM3(this.state.m3Enabled);
}

toggleTheme(value = !this.state.darkTheme) {
Expand Down Expand Up @@ -168,9 +170,13 @@ export class DevAppLayout {
(document.getElementById('theme-styles') as HTMLLinkElement).href = value
? 'theme-m3.css'
: 'theme.css';
this.state.m3Enabled = value;
setAppState(this.state);
}

this._iconRegistry.setDefaultFontSetClass(
value ? 'material-symbols-outlined' : 'material-icons',
);
this.state.m3Enabled = value;
setAppState(this.state);
}

getDensityClass() {
Expand Down
1 change: 1 addition & 0 deletions src/dev-app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Symbols+Outlined" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">

<!-- FontAwesome for mat-icon demo. -->
Expand Down
9 changes: 6 additions & 3 deletions src/material/icon/icon.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ component.
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 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`.

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`.

### Font icons with CSS

Expand Down

0 comments on commit 0cf81f3

Please sign in to comment.