Skip to content

getIcon

Official

Create an SVG from an iconId. Returns null if no icon associated with the iconId.

Import:

import { getIcon } from 'obsidian';

Example:

console.log(getIcon('dice')); // <svg>...</svg>

Signature:

function getIcon(iconId: string): SVGSVGElement | null

Parameters:

ParameterTypeDescription
iconIdstringthe icon ID.

Returns: SVGSVGElement | null — the SVG element or null if no icon associated with the iconId.

Example:

console.log(getIcon('dice')); // <svg>...</svg>

Links to this page: