SVG framework function: addAPIProvider
This tutorial is part of Iconify SVG Framework functions tutorial.
This function is part of API module and is not available in bundle without API support.
Function addAPIProvider() adds API provider.
Make sure you call it before retrieving icons from API provider, otherwise SVG framework will fail to retrieve icons. If you are not sure about execution order of your code, you can also use global variable IconifyProviders to set API providers configuration before loading SVG framework in a separate script. See API providers documentation for details.
API providers allow using icons from multiple API in the same document. For example, you can use default Iconify icons and custom icons from IconScout or Icons8 or custom API.
To support providers, syntax for icon names have been extended. Icon names in Iconify icon components have 3 parts:
All parts are separated by ":", provider is optional and can be skipped if empty.
- my-icons". Icon name for that provider is . : icon is retrieved from provider "
- : icon does not have provider, so provider is empty. Empty value is used for public Iconify API.
Function has the following parameters:
- provider, . Provider ID.
- config, . API configuration object.
// Array of host names
<span class="iconify" data-icon="@local:material-icons:home"></span>
See API providers documentation for details.