Skip to content

setAlias()

This function is part of IconSet class in Iconify Tools.

Function setAlias() adds new icon alias.

Alias

Icon alias is a different name for icon. It is usually used when renaming icon to allow users access icon using old name.

Usage

Function has the following parameters:

  • name, string. Icon name.
  • parent, string. Parent item name.

Function returns a simple true on success, false on failure.

Example

example.ts
tsimport { blankIconSet } from '@iconify/tools';

// Create icon set, add few icons
const iconSet = blankIconSet('test-prefix');
iconSet.setIcon('add', {
   body: '<path d="M17 15V8h-2v7H8v2h7v7h2v-7h7v-2z" fill="currentColor"/>',
   width: 32,
   height: 32,
});

iconSet.setIcon('caret-down', {
   body: '<path d="M24 12l-8 10l-8-10z" fill="currentColor"/>',
   width: 32,
   height: 32,
});
iconSet.setVariation('caret-up', 'caret-down', {
   vFlip: true,
});

iconSet.setAlias('plus', 'add');

// Export icon set
const data = iconSet.export();
console.log(JSON.stringify(data, null, '\t'));
Result:
json{
   "prefix": "test-prefix",
   "icons": {
       "add": {
           "body": "<path d=\"M17 15V8h-2v7H8v2h7v7h2v-7h7v-2z\" fill=\"currentColor\"/>"
       },
       "caret-down": {
           "body": "<path d=\"M24 12l-8 10l-8-10z\" fill=\"currentColor\"/>"
       }
   },
   "aliases": {
       "caret-up": {
           "parent": "caret-down",
           "vFlip": true
       },
       "plus": {
           "parent": "add"
       }
   },
   "width": 32,
   "height": 32
}

Released under the Apache 2.0 License.