Increasing engagement with icons

Stan Jobs
Stan Jobs

Instead of bloating our themes with extra font files containing icons that you may or may not use, we inline SVG icons which offer better page load performance and improved accessibility over font-based icon systems. Zendesk’s default Copenhagen theme recently made the same change with the release of the new theming API.

Our Icons page contains an excellent starter set of icons and there are many collections (and thousands of icons) available online for free like Bootstrap Icons, Heroicons and Icons8.

For more information about the differences between font-based and inline SVG icons, refer to this article.

Usage

Use .svg-icon with an inline SVG icon to make it scale in relation to surrounding text.

Heading 1

Heading 2

Heading 3

A paragraph of text

<h1 class="my-4">Heading 1 <svg class="svg-icon">...</svg></h1>
<h2 class="my-4">Heading 2 <svg class="svg-icon">...</svg></h2>
<h3 class="my-4">Heading 3 <svg class="svg-icon">...</svg></h3>
<p>A paragraph of text <svg class="svg-icon">...</svg></p>

A variety of different icons are included within each of our themes, which you can mix-and-match.

Some examples of commonly used SVG icons include:

thumbs-up

thumbs-down

star

pin

chevron-up

chevron-right

chevron-down

chevron-left

arrow-up

arrow-right

arrow-down

arrow-left

gear

Sizes

Use font size or sizing utilities can be used to control how large an icon appears.

<svg class="svg-icon text-red-500"></svg>
<svg class="svg-icon text-red-500 font-size-2xl"></svg>
<svg class="svg-icon text-red-500 h-6 w-6"></svg>

Colors

Use .fill-current or .stroke-current to set the fill or stroke color of the SVG to the current text color. Text color utilities can then be used to control the color of an icon.

<svg class="svg-icon font-size-2xl fill-current p-2 text-red-500"></svg>
<svg class="svg-icon font-size-2xl fill-current p-2 text-green-500"></svg>
<svg class="svg-icon font-size-2xl fill-current p-2 text-orange-500"></svg>
<svg class="svg-icon font-size-2xl fill-current p-2 text-gray-600"></svg>

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.