Skip to content

Commit 8eae80c

Browse files
CopilotScarletKuro
andauthored
add material icons preload guidance and font-display block
Agent-Logs-Url: https://github.com/MudBlazor/MudBlazor.Icons/sessions/9eec0945-aad2-4b3c-95af-58949556483e Co-authored-by: ScarletKuro <19953225+ScarletKuro@users.noreply.github.com>
1 parent be09e49 commit 8eae80c

3 files changed

Lines changed: 38 additions & 2 deletions

File tree

documentation/material_icons_usage.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,37 @@ To use the icons in your MudBlazor project, you can add the following CSS link t
1515
<link href="_content/MudBlazor.FontIcons.MaterialIcons/css/font.min.css" rel="stylesheet" />
1616
```
1717

18+
To reduce first-load flicker, preload the Material Icons font files before loading the stylesheet:
19+
20+
```html
21+
<link rel="preload"
22+
href="_content/MudBlazor.FontIcons.MaterialIcons/font/MaterialIcons.woff2"
23+
as="font"
24+
type="font/woff2"
25+
crossorigin>
26+
<link rel="preload"
27+
href="_content/MudBlazor.FontIcons.MaterialIcons/font/MaterialIconsOutlined.woff2"
28+
as="font"
29+
type="font/woff2"
30+
crossorigin>
31+
<link rel="preload"
32+
href="_content/MudBlazor.FontIcons.MaterialIcons/font/MaterialIconsRound.woff2"
33+
as="font"
34+
type="font/woff2"
35+
crossorigin>
36+
<link rel="preload"
37+
href="_content/MudBlazor.FontIcons.MaterialIcons/font/MaterialIconsSharp.woff2"
38+
as="font"
39+
type="font/woff2"
40+
crossorigin>
41+
<link rel="preload"
42+
href="_content/MudBlazor.FontIcons.MaterialIcons/font/MaterialIconsTwoTone.woff2"
43+
as="font"
44+
type="font/woff2"
45+
crossorigin>
46+
<link href="_content/MudBlazor.FontIcons.MaterialIcons/css/font.min.css" rel="stylesheet" />
47+
```
48+
1849
Alternatively, you can use the following CDN links:
1950

2051
```html

src/MudBlazor.FontIcons.MaterialIcons/wwwroot/css/font.css

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,39 @@
33
font-family: 'Material Icons';
44
font-style: normal;
55
font-weight: 400;
6+
font-display: block;
67
src: url(../font/MaterialIcons.woff2) format('woff2');
78
}
89

910
@font-face {
1011
font-family: 'Material Icons Outlined';
1112
font-style: normal;
1213
font-weight: 400;
14+
font-display: block;
1315
src: url(../font/MaterialIconsOutlined.woff2) format('woff2');
1416
}
1517

1618
@font-face {
1719
font-family: 'Material Icons Round';
1820
font-style: normal;
1921
font-weight: 400;
22+
font-display: block;
2023
src: url(../font/MaterialIconsRound.woff2) format('woff2');
2124
}
2225

2326
@font-face {
2427
font-family: 'Material Icons Sharp';
2528
font-style: normal;
2629
font-weight: 400;
30+
font-display: block;
2731
src: url(../font/MaterialIconsSharp.woff2) format('woff2');
2832
}
2933

3034
@font-face {
3135
font-family: 'Material Icons Two Tone';
3236
font-style: normal;
3337
font-weight: 400;
38+
font-display: block;
3439
src: url(../font/MaterialIconsTwoTone.woff2) format('woff2');
3540
}
3641
body {
@@ -115,4 +120,4 @@ body {
115120
direction: ltr;
116121
-moz-font-feature-settings: 'liga';
117122
-moz-osx-font-smoothing: grayscale;
118-
}
123+
}

src/MudBlazor.FontIcons.MaterialIcons/wwwroot/css/font.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)