SVG framework function: renderHTML

This tutorial is part of Iconify SVG Framework functions tutorial.

Function renderHTML() generates HTML code for icon.


Function has the following parameters:

  • name, string. Icon name.
  • customisations. Optional customizations object.

Function returns string, null if icon is not available.


if (Iconify.iconExists('mdi:home')) {
   node.innerHTML = Iconify.renderHTML('mdi:home');
const node = document.createElement('div');
node.innerHTML = Iconify.renderHTML('bi:stopwatch', {
   rotate: 1,
   height: 'auto',


Second parameter is optional icon customizations. Do not confuse it with placeholder data- attributes.

Available customizations:

IconifyIconCustomisations type is an object with the following optional properties, split into several categories.

Display mode:

  • inline, boolean. Inline or block mode. The default value is false.

Icon dimensions:

  • width, string | number | null. Icon width. The default value is null.
  • height, string | number | null. Icon height. The default value is null.

If neither of dimensions is set, height defaults to "1em".

Keyword "auto" sets dimension to original icon's dimensions found in viewBox.


  • hFlip, boolean. Flip icon horizontally. The default value is false.
  • vFlip, boolean. Flip icon vertically. The default value is false.
  • rotate, number. Rotation in 90 degrees increments. The default value is 0.

For more details about dimensions and alignment see icon dimensions documentation.

For more details about transformations see icon transformations documentation.

Rendering SVG

This function creates <string>. If you want to create <svg> element, use renderSVG() instead.