Skip to content

IconifyInfo 类型

所有 Iconify 库都共享通用的对象结构。它们在 @iconify/types NPM 包中被定义为类型。

有关类型的描述和 TypeScript 的简要说明,请参阅类型文档

本文介绍了 IconifyAlias 类型。

结构

类型 IconifyInfo 用于描述图标集的相关信息。

它具有以下必需属性:

  • namestring。图标集名称。
  • authorobject。作者信息(见下文)。
  • licenseobject。许可证信息(见下文)。

此外,它还包含许多可选属性,其中大多数属性用于在图标集列表中展示图标集数据:

  • totalnumber。图标集中的图标数量(见下文)。
  • versionstring。版本字符串。
  • samplesstring[]。要作为示例展示的图标名称数组。
  • heightnumber|number[]。图标网格尺寸。如果图标集混合了不同高度的图标,例如一半图标高 16 像素,另一半高 24 像素,则该值可以是数组。
  • displayHeightnumber。展示示例时使用的高度。值应介于 1624 之间。
  • categorystring。图标集列表中的分类。
  • tagsstring[]。标签列表,可用于筛选图标集(在版本 2 中添加)。
  • paletteboolean。如果所有图标均使用硬编码颜色,则设置为 true;如果所有图标均使用 currentColor,则设置为 false

作者

author 属性是一个对象,包含以下属性:

  • namestring。作者名称,必填。
  • urlstring。指向图标集网站的可选链接。通常指向 GitHub 仓库。

许可证

license 属性是一个对象,包含以下属性:

  • titlestring。人类可读的许可证名称,必填。
  • spdxstring。可选的 SPDX 许可证标识符。
  • urlstring。指向许可证文件的可选链接。

示例

json{
   "name": "Phosphor",
   "total": 5206,
   "version": "1.3.2",
   "author": {
       "name": "Phosphor Icons",
       "url": "https://github.com/phosphor-icons/phosphor-icons"
   },
   "license": {
       "title": "MIT",
       "spdx": "MIT"
   },
   "samples": [
       "folder-notch-open-duotone",
       "check-square-offset-thin",
       "pencil-line-fill"
   ],
   "height": 24,
   "displayHeight": 24,
   "category": "General",
   "palette": false
}
json{
   "name": "Emoji One (Colored)",
   "total": 1834,
   "version": "2.3.0",
   "author": {
       "name": "Emoji One",
       "url": "https://github.com/EmojiTwo/emojitwo"
   },
   "license": {
       "title": "CC BY 4.0",
       "spdx": "CC-BY-4.0",
       "url": "https://creativecommons.org/licenses/by/4.0/"
   },
   "samples": [
       "anxious-face-with-sweat",
       "cloud-with-snow",
       "studio-microphone"
   ],
   "height": 32,
   "displayHeight": 16,
   "category": "Emoji",
   "palette": true
}