在前端项目中引用Google Icon实现各种图标的显示

Google Icon

Google 提供了常见Icon集合,方便用户使用。目前有两个版本,Version1支持形状,填充和圆角等供用户选择。

Version2的功能更加强大,在第一版的基础上,支持调节线条的粗细。

Google Icon Link

Version 1 的具体实践

Version 1 支持的类型

  • Material+Icons
  • Material+Icons+Outlined
  • Material+Icons+Round
  • Material+Icons+Sharp
  • Material+Icons+TwoTone

示例 1

在项目中引用Google Icon的链接

html 复制代码
<link
href="<https://fonts.googleapis.com/icon?family=Material+Icons>"
rel="stylesheet"
/>  

在angular的项目文件中使用Google Icon

html 复制代码
<mat-icon>warning</mat-icon>
<mat-icon>warning_amber</mat-icon>
<mat-icon>warning_amber_outlined</mat-icon>  

效果图

示例2

在项目中引用Google Icon的链接, Material+Icons+Round是圆角的集合

html 复制代码
<link  
href="https://fonts.googleapis.com/icon?family=Material+Icons|Material+Icons+Round"
rel="stylesheet"
/>  

在angular的项目文件中使用Google Round Icon,注意 : 这里要引用material-icons-round的class名

html 复制代码
<mat-icon class="material-icons-round">warning</mat-icon>
<mat-icon class="material-icons-round">warning_amber</mat-icon>  

效果图

Version 2 的具体实践

Version 2 支持的类型

  • Material+Symbols
  • Material+Symbols+Rounded
  • Material+Symbols+Outlined
  • Material+Symbols+Sharp

示例 3

在项目中引用Google Icon Version2的链接

html 复制代码
<link  
href="https://fonts.googleapis.com/icon?family=Material+Icons|Material+Symbols+Rounded:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200"  
rel="stylesheet"
/>  

在项目中引用Google Icon的链接

html 复制代码
<mat-icon class="material-symbols-rounded">warning</mat-icon>  

CSS 文件中自定义的设置

css 复制代码
.material-symbols-rounded {  
    font-variation-settings:   
        'FILL' 0,
        'wght' 300,
        'GRAD' 0,  
        'opsz' 24
} 

效果图

相关推荐
CocoaKier1 天前
因 Google Ads 投流图片太暴露,险些导致谷歌包被下架
android·google
Flynt4 天前
Google 账号被封,验证器就成了死锁?我把 Authenticator 的导出码拆到了字节层
安全·google
掘金安东尼4 天前
Google Antigravity 和 Gemini Neon:哪些行为会封号,怎么降低风险(Flavio Copes 全文转译)
人工智能·google·gemini
黄林晴7 天前
Android 开了 R8,为什么 SDK 还在阻止优化?
android·google
stormzhangV8 天前
一文说清楚 Neon 到底有多强?
人工智能·google·aigc
zhangfeng11338 天前
Gemini 4 Neon 发布:Carbon/Hydrogen 之外的「均衡档」成型,三杯模型矩阵集齐
google·模型发布·gemini4neon·分层策略·复杂编码
Flynt10 天前
AI 生成的界面,能放心点吗?我把 Google A2UI 的三层防线拆开测了一遍
前端·google·agent
沉默王二11 天前
Gemini 4 Neon+Antigravity,干活真猛啊。
google·agent·gemini
stormzhangV15 天前
Google 重返第一梯队
人工智能·google·aigc
云卷云舒___________21 天前
突发:Gemini 4 Hydrogen内测,Grok 4.8推送,Qwen Code 1.0开源,格局一夜生变 | AI日报11.12
google·qwen·grok·gemini·xai·ai日报·qwencode