robertgarrigos's picture

The new icon API documentation says we can add icons as inline HTML, but in fact it only explains how to add them with php or javascript. Is there an easy way to add an icon as inline HTML within in a custom block, for instance?

Most helpful answers

<img src="/core/misc/icons/alarm-fill.svg" class="core-icon">Display text

.core-icon { width: 16px; height: 16px; margin-right: 10px; }

or with CSS background-image.

/* I recommend stylish Material Icons https://fonts.google.com/icons */

Comments

<img src="/core/misc/icons/alarm-fill.svg" class="core-icon">Display text

.core-icon { width: 16px; height: 16px; margin-right: 10px; }

or with CSS background-image.

/* I recommend stylish Material Icons https://fonts.google.com/icons */

Olafski's picture

Thanks for the hint, @Enthuisiast, very helpful! Not easy for every content editor but good enough if you know how to find the icon names.

I was curious and tried to control the icon size directly, without the need to touch CSS. Here we are:

<img src="/core/misc/icons/alarm-fill.svg" width="16">

This works with Basis as default theme which sets the height of images to auto.