在前端项目中引用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-roundclass

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
} 

效果图

相关推荐
程序员爱钓鱼13 小时前
Go语言实战案例-读取用户输入并打印
后端·google·go
奇舞精选1 天前
用 AI 提效的新方式:全面体验 Google Gemini CLI
前端·google·ai编程
程序员爱钓鱼2 天前
限流、控并发、减GC!一文搞懂Go项目资源优化的正确姿势
后端·google·go
程序员爱钓鱼2 天前
Go项目上线部署最佳实践:Docker容器化从入门到进阶
后端·google·go
程序员爱钓鱼4 天前
Go语言泛型-泛型对代码结构的优化
后端·google·go
程序员鱼皮7 天前
用 AI 制作超长视频,保姆级教程!
google·程序员·aigc
程序员爱钓鱼7 天前
Go语言项目工程化 —— 日志、配置、错误处理规范
后端·google·go
程序员爱钓鱼8 天前
Go语言实战指南 —— Go中的反射机制:reflect 包使用
后端·google·go
摆烂工程师17 天前
此账号无法订阅Google One AI Pro 解决方法 (This account isn’t eligible for Google AI plan)
前端·后端·google