ionicons README

The project's README from github.com/ionic-team/ionicons. As one markdown file: README.md.

Ionicons

Ionicons is a completely open-source icon set with 1,300 icons crafted for web, iOS, Android, and desktop apps. Ionicons was built for Ionic Framework, so icons have both Material Design and iOS versions.

Note: All brand icons are trademarks of their respective owners. The use of these trademarks does not indicate endorsement of the trademark holder by Ionic, nor vice versa.

We intend for this icon pack to be used with Ionic, but it’s by no means limited to it. Use them wherever you see fit, personal or commercial. They are free to use and licensed under MIT.

Contributing

Thanks for your interest in contributing! Read up on our guidelines for contributing and then look through our issues with a help wanted label.

Using the Web Component

The Ionicons Web Component is an easy and performant way to use Ionicons in your app. The component will dynamically load an SVG for each icon, so your app is only requesting the icons that you need.

Also note that only visible icons are loaded, and icons that are "below the fold" and hidden from the user's view do not make fetch requests for the svg resource.

Installation

If you're using Ionic Framework, Ionicons is packaged by default, so no installation is necessary. Want to use Ionicons without Ionic Framework? Place the following <script> near the end of your page, right before the closing </body> tag, to enable them.

<script type="module" src="https://esm.sh/ionicons@latest/loader"></script>
<script nomodule src="https://esm.sh/ionicons@latest/loader"></script>

you can replace latest to pick any version of Ionicon, e.g.:

<script type="module" src="https://esm.sh/[email protected]/loader"></script>
<script nomodule src="https://esm.sh/[email protected]/loader"></script>

Basic usage

To use a built-in icon from the Ionicons package, populate the name attribute on the ion-icon component:

<ion-icon name="heart"></ion-icon>

Custom icons

To use a custom SVG, provide its url in the src attribute to request the external SVG file. The src attribute works the same as <img src="..."> in that the url must be accessible from the webpage that's making a request for the image. Additionally, the external file can only be a valid svg and does not allow scripts or events within the svg element.

<ion-icon src="/path/to/external/file.svg"></ion-icon>

Custom Asset Path

If you have a different set of icons you would like to load or if the Ionicon icons are hosted on a different page or path, you can set the asset url from which Ionicons pulls the icons via:

import { setAssetPath, addIcons } from 'ionicons';
import { add, logoIonic, save } from 'ionicons/icons';

// set root path for loading icons to "<root>/public/svg"
setAssetPath(`${window.location.origin}/public/svg/`);

// only load specific icons
addIcons({ add, logoIonic, save });

This allows the use of named icons like this:

<!-- now pulls the svg from "<root>/public/svg/heart.svg" -->
<ion-icon name="heart"></ion-icon>

Variants

Each app icon in Ionicons has a filled, outline and sharp variant. These different variants are provided to make your app feel native to a variety of platforms. The filled variant uses the default name without a suffix. Note: Logo icons do not have outline or sharp variants.

<ion-icon name="heart"></ion-icon> <!--filled-->
<ion-icon name="heart-outline"></ion-icon> <!--outline-->
<ion-icon name="heart-sharp"></ion-icon> <!--sharp-->

Platform specificity

When using icons in Ionic Framework you can specify different icons per platform. Use the md and ios attributes and provide the platform-specific icon/variant name.

<ion-icon ios="heart-outline" md="heart-sharp"></ion-icon>

Size

To specify the icon size, you can use the size attribute for our pre-defined font sizes.

<ion-icon size="small"></ion-icon>
<ion-icon size="large"></ion-icon>

Or you can set a specific size by applying the font-size CSS property on the ion-icon component. It's recommended to use pixel sizes that are a multiple of 8 (8, 16, 32, 64, etc.)

ion-icon {
  font-size: 64px;
}

Color

Specify the icon color by applying the color CSS property on the ion-icon component.

ion-icon {
  color: blue;
}

Stroke width

When using an outline icon variant it is possible to adjust the stroke width, for improved visual balance relative to the icon's size or relative to the width of adjacent text. You can set a specific size by applying the --ionicon-stroke-width CSS custom property to the ion-icon component. The default value is 32px.

<ion-icon name="heart-outline"></ion-icon>
ion-icon {
  --ionicon-stroke-width: 16px;
}

Migrating from v4

See the 5.0 release notes for a list of icon deletions/renames.

License

Ionicons is licensed under the MIT license.

ionicons (ionic-team/ionicons)

Searching Database…

18.2K ·GitHub
这是什么?Ionicons 是一套开源图标库,包含 1,300 个手工精心设计的图标,适用于网页、iOS、Android 和桌面应用,专为 Ionic Framework 打造,但也可在任何地方使用。
这是字体图标包还是基于 SVG 的?它以独立的 SVG 图标形式提供,通过使用 Stencil 构建的 Web 组件交付,该组件会为你使用的每个图标动态加载对应的 SVG。
怎样把它添加到项目中?如果你使用 Ionic Framework,它已经包含在内;否则请添加 ionicons 脚本或模块,然后通过 setAssetPath 和 addIcons 导入图标,例如 'add, logoIonic, save'。
使用这些图标是否需要 Ionic Framework?不需要。Ionicons 可以脱离 Ionic Framework 单独使用,只需导入 Web 组件以及你需要的特定图标即可。
我可以随意使用品牌或标志类图标吗?图标集本身采用 MIT 许可证,可免费用于个人或商业用途;但品牌图标仍归其各自所有者所有,使用它们并不代表获得了背书。
这个库也适用于 Android 应用吗?能否呈现正确的 Material 风格?可以。由于它是为 Ionic Framework 打造的,每个图标都同时包含 Material Design 版本和 iOS 风格版本,并支持网页、iOS、Android 和桌面应用。
如何自定义图标的颜色或大小?图标大小跟随 font-size,颜色跟随 'ion-icon' 元素上的 CSS color 属性;你还可以通过 '--ionicon-stroke-width' CSS 变量自定义描边宽度。
它是否只加载实际用到的图标?是的。Web 组件会按图标惰性获取 SVG,并跳过加载隐藏的或位于首屏以下的图标,从而尽量减少请求数量。
v4 到 v5 之间发生了什么变化?在升级到 v5 时,有若干图标被删除或重命名;README 中提供了 5.0 发布说明的链接,其中有完整的迁移清单。
Creator
ionic-team
Size
28.3 MB
Stars
18.2K
Age
13y
Commits · 90 Days