在前端项目中引用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语言实战案例——进阶与部署篇:性能优化与 pprof 性能分析实践
后端·google·go
程序员爱钓鱼1 天前
Go语言实战案例——进阶与部署篇:使用Go编写系统服务(如守护进程)
后端·google·go
闲云S2 天前
Lit开发:字体图标的使用
前端·web components·icon
程序员爱钓鱼2 天前
Go语言实战案例——进阶与部署篇:使用Docker部署Go服务
后端·google·go
蓝银草同学3 天前
阿里 Iconfont 项目丢失?手把手教你将已引用的 SVG 图标下载到本地
前端·icon
deephub8 天前
Google开源Tunix:JAX生态的LLM微调方案来了
人工智能·深度学习·google·微调·大语言模型·jax
万兴丶13 天前
Google Play合规指南:您的应用所使用的原生库不支持 16 KB 内存页面大小.快速解决
unity·google
程序员爱钓鱼18 天前
Go语言100个实战案例-进阶与部署篇:使用Go打包生成可执行文件
后端·google·go
Carson带你学Android22 天前
Android PC时代已到来?Chrome OS将和Android合并!
android·google·chrome os
程序员爱钓鱼22 天前
Go语言实战案例-项目实战篇:使用Go调用第三方API(如天气、翻译)
后端·google·go