SVG framework function: renderSVG

This tutorial is part of Iconify SVG Framework functions tutorial.

Function renderSVG() creates <svg> element.


Function has the following parameters:

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

Function returns <svg> element, null if icon is not available.


if (Iconify.iconExists('mdi:home')) {
   class="iconify iconify--mdi"
   preserveAspectRatio="xMidYMid meet"
   viewBox="0 0 24 24"

   <path d="M10 20v-6h4v6h5v-8h3L12 3L2 12h3v8h5z" fill="currentColor"></path>
const node = document.createElement('div');
const icon = Iconify.renderSVG('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 HTML

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