Support - Why is my svg / icon not rendering correctly ?

Undraw Icon Design Re 9web

About

This article explains why your svg or icon may not render correctly with Combostrap and brings two solutions.

If the icon that you are using is from one of our supported icon library, contact us or create a ticket

If your icon or svg does not render correctly, this is ultimately caused by a styling issue because ComboStrap suppress them by default with the svg optimization (along with all class attributes).

Why is the style suppressed by default ?

Style Conflict

By default, a icon or any svg should not use the css style element because:

  • the style will leak into the current page
  • the style generally contains the same class names across icons (they are generated by the icon/svg application. For instance, cls-1, cls-2, from photoshop).

Below, you can see examples of such icon:

If you put this two icon on a page, the second will be a blank square 1) because:

  • the share the same class cls-1 (photoshop generated class)
  • and the first one has a transparency attribute.

Color Conflict

We allows a user to change the color for any icon. If there was any style, it would not be possible because there would be a conflict between:

  • the color of the user
  • the color of the style

Solution

Modify your file

The first solution is to change your svg file by replacing any style attribute or element by the corresponding svg painting attribute that are:

  • fill
  • stroke

Example:

  • You could replace this declaration
<defs>
   <style>.cls-1{fill:#fff;}</style>
</defs>
<path class="cls-1">
  • With
<path fill="#fff">

Preserve

If you are sure that the style will not leak and that you want to preserve them, you can add the preserve attribute.

It will:

  • preserve the style
  • and serve the svg as image (to not leak the style)

Example:

<icon name="carbon:logo-tumblr" preserve="style"/>

{{:combostrap:icons:carbon:logo-tumblr.svg?24&preserve=style}}

It will preserve the style but also the class and id attributes.




Showcase yourself and your brand

Get free news, tips, and tricks
to create a remarkable experience for your readers.




Recommended Pages
Icon Default Location Combostrap
ComboStrap - Icon Component

An icon component that makes it easy to add icon to your pages
SVG to fitViewport 1Viewport 2--------------- meet ---------------xMin*xMid*xMax*---------- meet ----------*YMin*YMid*YMax---------- slice ----------xMin*xMid*xMax*--------------- slice ---------------*YMin*YMid*YMax
How to use a SVG in ComboStrap

ComboStrap supports natively SVG and allows you to use them as image, illustration and background
Svgomg
Svg Optimization included

ComboStrap optimizes by default all SVG making them smaller without losing any quality.



Task Runner