Type alias IconLoader

IconLoader: ((name) => Promise<IconData>)

Type declaration

    • (name): Promise<IconData>
    • Callback with a custom icon loader. Allows the Element to load icon data from a custom source. Remember to assign the icon loader before defining the lord-icon custom element to take effect.

      Example:

      import lottie from 'lottie-web';
      import { defineElement, Element } from '@lordicon/element';

      Element.setIconLoader(async (name) => {
      const response = await fetch(`https://example.com/${name}.json`);
      return await response.json();
      });

      defineElement(lottie.loadAnimation);

      Parameters

      • name: string

        Icon name.

      Returns Promise<IconData>