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

效果图

相关推荐
程序员爱钓鱼2 小时前
Go语言实战案例-判断一个数是否为质数
后端·google·go
程序员爱钓鱼2 小时前
Go语言实战案例-读取本地文本文件内容
后端·google·go
程序员爱钓鱼1 天前
Go语言实战案例-模拟登录验证(用户名密码)
后端·google·go
程序员爱钓鱼1 天前
Go语言实战案例-斐波那契数列生成器
后端·google·go
stanleychan872 天前
轻松扩展 Gemini CLI:MCP 服务配置实战指南
google
程序员爱钓鱼2 天前
Go语言100个实战案例 - 找出切片中的最大值与最小值
后端·google·go
程序员爱钓鱼3 天前
Go语言数组排序(冒泡排序法)—— 用最直观的方式掌握排序算法
后端·google·go
清霜之辰3 天前
安卓基于 FirebaseAuth 实现 google 登录
android·google·auth·firebase
程序员爱钓鱼4 天前
Go语言统计字符串中每个字符出现的次数 — 简易频率分析器
后端·google·go
程序员爱钓鱼5 天前
Go语言实战案例-判断回文字符串-是不是正着念反着念都一样?
后端·google·go