Skip to content

addIcon

Official

Adds an icon to the library.

Import:

import { addIcon } from 'obsidian';

Example:

addIcon('my-icon', '<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><circle cx="50" cy="50" r="40"/></svg>');

Signature:

function addIcon(iconId: string, svgContent: string): void

Parameters:

ParameterTypeDescription
iconIdstringthe icon ID.
svgContentstringthe content of the SVG.

Returns: void

Example:

addIcon('my-icon', '<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><circle cx="50" cy="50" r="40"/></svg>');