Skip to content

Premium hand-crafted icons built by Ionic, for Ionic apps and web apps everywhere 🌎

License

Notifications You must be signed in to change notification settings

ionic-team/ionicons

Repository files navigation

Ionicons

Ioniconsis a completely open-source icon set with 1,300 icons crafted for web, iOS, Android, and desktop apps. Ionicons was built forIonic 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 withIonic,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 underMIT.

Contributing

Thanks for your interest in contributing! Read up on our guidelines for contributing and then look through our issues with ahelp 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 usingIonic 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.

<scripttype= "module"src= "https://cdn.jsdelivr.net/npm/ionicons@latest/dist/ionicons/ionicons.esm.js"></script>
<scriptnomodulesrc= "https://cdn.jsdelivr.net/npm/ionicons@latest/dist/ionicons/ionicons.js"></script>

Basic usage

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

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

Custom icons

To use a custom SVG, provide its url in thesrcattribute to request the external SVG file. Thesrcattribute 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-iconsrc= "/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}from'@stencil/core'

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

This allows the use of named icons like this:

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

Variants

Each app icon in Ionicons has afilled,outlineandsharpvariant. 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-iconname= "heart"></ion-icon><!--filled-->
<ion-iconname= "heart-outline"></ion-icon><!--outline-->
<ion-iconname= "heart-sharp"></ion-icon><!--sharp-->

Platform specificity

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

<ion-iconios= "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-iconsize= "small"></ion-icon>
<ion-iconsize= "large"></ion-icon>

Or you can set a specific size by applying thefont-sizeCSS property on theion-iconcomponent. 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 thecolorCSS property on theion-iconcomponent.

ion-icon{
color:blue;
}

Stroke width

When using anoutlineicon 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-widthCSS custom property to theion-iconcomponent. The default value is 32px.

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

Migrating from v4

See the5.0 release notesfor a list of icon deletions/renames.

License

Ionicons is licensed under theMIT license.

Related