SVG framework function: iconExists

This tutorial is part of Iconify SVG Framework functions tutorial.

Function iconExists() checks if icon data is available for rendering.

Usage

Function has the following parameter:

  • name, string. Icon name.

Function returns boolean value: true if icon is available, false if icon is not available.

Example

function renderLeftArrow() {
   // Check if 'bi:arrow-left' is available
   if (Iconify.iconExists('bi:arrow-left')) {
       // Return HTML for 'bi:arrow-left'
       return Iconify.renderHTML('bi:arrow-left');
   }

   // Load icon. Bad example because this should use a callback to re-render arrow, but
   // this code example is about iconExists(), not loadIcons()
   Iconify.loadIcons(['bi:arrow-left']);

   // Return '<'
   return '&lt;';
}