Skip to content

SVG framework function: iconExists

This tutorial is part of Iconify SVG Framework functions tutorial.

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

Usage

The function has the following parameter:

  • name, string. Icon name.

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

Example

jsfunction 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;';
}

Released under the Apache 2.0 License.