在前端项目中引用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,[email protected],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
} 

效果图

相关推荐
win4r14 小时前
🚀颠覆传统智能体!ADK谷歌最强AI智能体发布!支持MCP与ollama!Agent Development Kit详细教程!超越AutoGen和LangCh
google·aigc·openai
Justin3go1 天前
谷歌 Agent2Agent(A2A)协议深度调研报告
google·openai·mcp
Captaincc1 天前
谷歌版MCP来了:Agent2Agent协议,实现跨平台AI Agent互联
前端·google·mcp
MervynZ1 天前
Agent to Agent(A2A)一文全了解
人工智能·google·开源
Captaincc2 天前
Google 放大招发布全新AI 编程Firebase Studio,3 分钟构建应用
google·ai编程
牢鹅出海10 天前
2月近10万款应用被谷歌下架,游戏、社交、工具类App遭受重创
google
牢鹅出海10 天前
口气了解Google Play审核机制,科学应对"谷歌卡审"危机
google
芦半山15 天前
谷歌决定闭源Android?Fake News!
android·google
几米哥23 天前
Gemini Advanced新功能详解:AI创作与协作的终极解决方案
google·gemini
听吉米讲故事1 个月前
Data Science Agent in Colab完全指南:AI驱动的智能数据分析助手
google·数据分析·gemini·colab