Include a font icon in a single widget

If you only want one widget to have access to a font icon, include the font icon in a single widget.

Before you begin

Role required: admin or sp_admin

About this task

Adding an icon to a specific widget keeps the icon scoped and prevents it from interfering with other CSS on the page.

Procedure

  1. In the platform UI, navigate to Service Portal > Widgets, then click the widget you want to add an icon to.
  2. Attach the individual icon file to the widget record.
  3. In the HTML template, include something like the following:
    <div>
    <i class='font-family'>icon_name</i> you did it!
    </div>

    Make sure the class is exactly the same as the font family called out in the CSS. For example <i class='material-icons'> should be the same as the .material-icons included in the CSS. The icon_name should match the name of the file you attached.

  4. In the CSS field for the widget, add the CSS for the font-icon definition. Most font-icon sets include a CSS file similar to the material icons one used below. Use the sys_id of the attachment as the src in the CSS.

    Widget with icon set attached and sample CSS

Result

An icon that you can select in the widget or widget instance. Example icon that matches the HTML in the widget example, with a check circle that says "you did it!"

What to do next

To use custom font-icons across widgets, add the icon to a page or make it a widget dependency.