Light Dark System

Icon

<p-icon> | PIcon
Since 1.0 stable

Icons are symbols that can be used to represent various options within an application.

Pure UI comes bundled with over 1,500 icons courtesy of the Bootstrap Icons project. These icons are part of the default icon library. If you prefer, you can register custom icon libraries as well.

Default Icons

All available icons in the default icon library are shown below. Click or tap on any icon to copy its name, then you can use it in your HTML like this.

<p-icon name="icon-name-here"></p-icon>

Examples

Colors

Icons inherit their color from the current text color. Thus, you can set the color property on the <p-icon> element or an ancestor to change the color.

<div style="color: #4a90e2;">
  <p-icon name="exclamation-triangle"></p-icon>
  <p-icon name="archive"></p-icon>
  <p-icon name="battery-charging"></p-icon>
  <p-icon name="bell"></p-icon>
</div>
<div style="color: #9013fe;">
  <p-icon name="clock"></p-icon>
  <p-icon name="cloud"></p-icon>
  <p-icon name="download"></p-icon>
  <p-icon name="file-earmark"></p-icon>
</div>
<div style="color: #417505;">
  <p-icon name="flag"></p-icon>
  <p-icon name="heart"></p-icon>
  <p-icon name="image"></p-icon>
  <p-icon name="lightning"></p-icon>
</div>
<div style="color: #f5a623;">
  <p-icon name="mic"></p-icon>
  <p-icon name="search"></p-icon>
  <p-icon name="star"></p-icon>
  <p-icon name="trash"></p-icon>
</div>
import PIcon from 'pure-uikit/dist/react/icon';

const App = () => (
  <>
    <div style={{ color: '#4a90e2' }}>
      <PIcon name="exclamation-triangle"></PIcon>
      <PIcon name="archive"></PIcon>
      <PIcon name="battery-charging"></PIcon>
      <PIcon name="bell"></PIcon>
    </div>
    <div style={{ color: '#9013fe' }}>
      <PIcon name="clock"></PIcon>
      <PIcon name="cloud"></PIcon>
      <PIcon name="download"></PIcon>
      <PIcon name="file-earmark"></PIcon>
    </div>
    <div style={{ color: '#417505' }}>
      <PIcon name="flag"></PIcon>
      <PIcon name="heart"></PIcon>
      <PIcon name="image"></PIcon>
      <PIcon name="lightning"></PIcon>
    </div>
    <div style={{ color: '#f5a623' }}>
      <PIcon name="mic"></PIcon>
      <PIcon name="search"></PIcon>
      <PIcon name="star"></PIcon>
      <PIcon name="trash"></PIcon>
    </div>
  </>
);

Sizing

Icons are sized relative to the current font size. To change their size, set the font-size property on the icon itself or on a parent element as shown below.

<div style="font-size: 32px;">
  <p-icon name="exclamation-triangle"></p-icon>
  <p-icon name="archive"></p-icon>
  <p-icon name="battery-charging"></p-icon>
  <p-icon name="bell"></p-icon>
  <p-icon name="clock"></p-icon>
  <p-icon name="cloud"></p-icon>
  <p-icon name="download"></p-icon>
  <p-icon name="file-earmark"></p-icon>
  <p-icon name="flag"></p-icon>
  <p-icon name="heart"></p-icon>
  <p-icon name="image"></p-icon>
  <p-icon name="lightning"></p-icon>
  <p-icon name="mic"></p-icon>
  <p-icon name="search"></p-icon>
  <p-icon name="star"></p-icon>
  <p-icon name="trash"></p-icon>
</div>
import PIcon from 'pure-uikit/dist/react/icon';

const App = () => (
  <div style={{ fontSize: '32px' }}>
    <PIcon name="exclamation-triangle" />
    <PIcon name="archive" />
    <PIcon name="battery-charging" />
    <PIcon name="bell" />
    <PIcon name="clock" />
    <PIcon name="cloud" />
    <PIcon name="download" />
    <PIcon name="file-earmark" />
    <PIcon name="flag" />
    <PIcon name="heart" />
    <PIcon name="image" />
    <PIcon name="lightning" />
    <PIcon name="mic" />
    <PIcon name="search" />
    <PIcon name="star" />
    <PIcon name="trash" />
  </div>
);

Labels

For non-decorative icons, use the label attribute to announce it to assistive devices.

<p-icon name="star-fill" label="Add to favorites"></p-icon>
import PIcon from 'pure-uikit/dist/react/icon';

const App = () => <PIcon name="star-fill" label="Add to favorites" />;

Custom Icons

Custom icons can be loaded individually with the src attribute. Only SVGs on a local or CORS-enabled endpoint are supported. If you’re using more than one custom icon, it might make sense to register a custom icon library.

<p-icon src="https://pureui.xyz/assets/images/shoe.svg" style="font-size: 8rem;"></p-icon>
import PIcon from 'pure-uikit/dist/react/icon';

const App = () => <PIcon src="https://pureui.xyz/assets/images/shoe.svg" style={{ fontSize: '8rem' }}></PIcon>;

Icon Libraries

You can register additional icons to use with the <p-icon> component through icon libraries. Icon files can exist locally or on a CORS-enabled endpoint (e.g. a CDN). There is no limit to how many icon libraries you can register and there is no cost associated with registering them, as individual icons are only requested when they’re used.

Pure UI ships with two built-in icon libraries, default and system. The default icon library contains all of the icons in the Bootstrap Icons project. The system icon library contains only a small subset of icons that are used internally by Pure UI components.

To register an additional icon library, use the registerIconLibrary() function that’s exported from utilities/icon-library.js. At a minimum, you must provide a name and a resolver function. The resolver function translates an icon name to a URL where the corresponding SVG file exists. Refer to the examples below to better understand how it works.

If necessary, a mutator function can be used to mutate the SVG element before rendering. This is necessary for some libraries due to the many possible ways SVGs are crafted. For example, icons should ideally inherit the current text color via currentColor, so you may need to apply fill="currentColor or stroke="currentColor" to the SVG element using this function.

Here’s an example that registers an icon library located in the /assets/icons directory.

<script type="module">
  import { registerIconLibrary } from "/dist/utilities/icon-library.js";

  registerIconLibrary("my-icons", {
    resolver: name => `/assets/icons/${name}.svg`,
    mutator: svg => svg.setAttribute("fill", "currentColor"),
  });
</script>

To display an icon, set the library and name attributes of an <p-icon> element.

<!-- This will show the icon located at /assets/icons/smile.svg -->
<p-icon library="my-icons" name="smile"></p-icon>

If an icon is used before registration occurs, it will be empty initially but shown when registered.

The following examples demonstrate how to register a number of popular, open source icon libraries via CDN. Feel free to adapt the code as you see fit to use your own origin or naming conventions.

Boxicons

This will register the Boxicons library using the jsDelivr CDN. This library has three variations: regular (bx-*), solid (bxs-*), and logos (bxl-*). A mutator function is required to set the SVG’s fill to currentColor.

Icons in this library are licensed under the Creative Commons 4.0 License.



<script type="module">
  import { registerIconLibrary } from '/dist/utilities/icon-library.js';

  registerIconLibrary('boxicons', {
    resolver: name => {
      let folder = 'regular';
      if (name.substring(0, 4) === 'bxs-') folder = 'solid';
      if (name.substring(0, 4) === 'bxl-') folder = 'logos';
      return `https://cdn.jsdelivr.net/npm/boxicons@2.0.5/svg/${folder}/${name}.svg`;
    },
    mutator: svg => svg.setAttribute('fill', 'currentColor')
  });
</script>

<div style="font-size: 24px;">
  <p-icon library="boxicons" name="bx-bot"></p-icon>
  <p-icon library="boxicons" name="bx-cookie"></p-icon>
  <p-icon library="boxicons" name="bx-joystick"></p-icon>
  <p-icon library="boxicons" name="bx-save"></p-icon>
  <p-icon library="boxicons" name="bx-server"></p-icon>
  <p-icon library="boxicons" name="bx-wine"></p-icon>
  <br />
  <p-icon library="boxicons" name="bxs-bot"></p-icon>
  <p-icon library="boxicons" name="bxs-cookie"></p-icon>
  <p-icon library="boxicons" name="bxs-joystick"></p-icon>
  <p-icon library="boxicons" name="bxs-save"></p-icon>
  <p-icon library="boxicons" name="bxs-server"></p-icon>
  <p-icon library="boxicons" name="bxs-wine"></p-icon>
  <br />
  <p-icon library="boxicons" name="bxl-apple"></p-icon>
  <p-icon library="boxicons" name="bxl-chrome"></p-icon>
  <p-icon library="boxicons" name="bxl-edge"></p-icon>
  <p-icon library="boxicons" name="bxl-firefox"></p-icon>
  <p-icon library="boxicons" name="bxl-opera"></p-icon>
  <p-icon library="boxicons" name="bxl-microsoft"></p-icon>
</div>

Lucide

This will register the Lucide icon library using the jsDelivr CDN. This project is a community-maintained fork of the popular Feather icon library.

Icons in this library are licensed under the MIT License.

<div style="font-size: 24px;">
  <p-icon library="lucide" name="feather"></p-icon>
  <p-icon library="lucide" name="pie-chart"></p-icon>
  <p-icon library="lucide" name="settings"></p-icon>
  <p-icon library="lucide" name="map-pin"></p-icon>
  <p-icon library="lucide" name="printer"></p-icon>
  <p-icon library="lucide" name="shopping-cart"></p-icon>
</div>

<script type="module">
  import { registerIconLibrary } from '/dist/utilities/icon-library.js';

  registerIconLibrary('lucide', {
    resolver: name => `https://cdn.jsdelivr.net/npm/lucide-static@0.16.29/icons/${name}.svg`
  });
</script>

Font Awesome

This will register the Font Awesome Free library using the jsDelivr CDN. This library has three variations: regular (far-*), solid (fas-*), and brands (fab-*). A mutator function is required to set the SVG’s fill to currentColor.

Icons in this library are licensed under the Font Awesome Free License. Some of the icons that appear on the Font Awesome website require a license and are therefore not available in the CDN.



<script type="module">
  import { registerIconLibrary } from '/dist/utilities/icon-library.js';

  registerIconLibrary('fa', {
    resolver: name => {
      const filename = name.replace(/^fa[rbs]-/, '');
      let folder = 'regular';
      if (name.substring(0, 4) === 'fas-') folder = 'solid';
      if (name.substring(0, 4) === 'fab-') folder = 'brands';
      return `https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.1/svgs/${folder}/${filename}.svg`;
    },
    mutator: svg => svg.setAttribute('fill', 'currentColor')
  });
</script>

<div style="font-size: 24px;">
  <p-icon library="fa" name="far-bell"></p-icon>
  <p-icon library="fa" name="far-comment"></p-icon>
  <p-icon library="fa" name="far-hand-point-right"></p-icon>
  <p-icon library="fa" name="far-hdd"></p-icon>
  <p-icon library="fa" name="far-heart"></p-icon>
  <p-icon library="fa" name="far-star"></p-icon>
  <br />
  <p-icon library="fa" name="fas-archive"></p-icon>
  <p-icon library="fa" name="fas-book"></p-icon>
  <p-icon library="fa" name="fas-chess-knight"></p-icon>
  <p-icon library="fa" name="fas-dice"></p-icon>
  <p-icon library="fa" name="fas-pizza-slice"></p-icon>
  <p-icon library="fa" name="fas-scroll"></p-icon>
  <br />
  <p-icon library="fa" name="fab-apple"></p-icon>
  <p-icon library="fa" name="fab-chrome"></p-icon>
  <p-icon library="fa" name="fab-edge"></p-icon>
  <p-icon library="fa" name="fab-firefox"></p-icon>
  <p-icon library="fa" name="fab-opera"></p-icon>
  <p-icon library="fa" name="fab-microsoft"></p-icon>
</div>

Heroicons

This will register the Heroicons library using the jsDelivr CDN.

Icons in this library are licensed under the MIT License.

<script type="module">
  import { registerIconLibrary } from '/dist/utilities/icon-library.js';

  registerIconLibrary('heroicons', {
    resolver: name => `https://cdn.jsdelivr.net/npm/heroicons@2.0.1/24/outline/${name}.svg`
  });
</script>

<div style="font-size: 24px;">
  <p-icon library="heroicons" name="chat-bubble-left"></p-icon>
  <p-icon library="heroicons" name="cloud"></p-icon>
  <p-icon library="heroicons" name="cog"></p-icon>
  <p-icon library="heroicons" name="document-text"></p-icon>
  <p-icon library="heroicons" name="gift"></p-icon>
  <p-icon library="heroicons" name="speaker-wave"></p-icon>
</div>

Iconoir

This will register the Iconoir library using the jsDelivr CDN.

Icons in this library are licensed under the MIT License.

<script type="module">
  import { registerIconLibrary } from '/dist/utilities/icon-library.js';

  registerIconLibrary('iconoir', {
    resolver: name => `https://cdn.jsdelivr.net/gh/lucaburgio/iconoir@latest/icons/${name}.svg`
  });
</script>

<div style="font-size: 24px;">
  <p-icon library="iconoir" name="check-circled-outline"></p-icon>
  <p-icon library="iconoir" name="drawer"></p-icon>
  <p-icon library="iconoir" name="keyframes"></p-icon>
  <p-icon library="iconoir" name="headset-help"></p-icon>
  <p-icon library="iconoir" name="color-picker"></p-icon>
  <p-icon library="iconoir" name="wifi"></p-icon>
</div>

Ionicons

This will register the Ionicons library using the jsDelivr CDN. This library has three variations: outline (default), filled (*-filled), and sharp (*-sharp). A mutator function is required to polyfill a handful of styles we’re not including.

Icons in this library are licensed under the MIT License.



<script type="module">
  import { registerIconLibrary } from '/dist/utilities/icon-library.js';

  registerIconLibrary('ionicons', {
    resolver: name => `https://cdn.jsdelivr.net/npm/ionicons@5.1.2/dist/ionicons/svg/${name}.svg`,
    mutator: svg => {
      svg.setAttribute('fill', 'currentColor');
      svg.setAttribute('stroke', 'currentColor');
      [...svg.querySelectorAll('.ionicon-fill-none')].map(el => el.setAttribute('fill', 'none'));
      [...svg.querySelectorAll('.ionicon-stroke-width')].map(el => el.setAttribute('stroke-width', '32px'));
    }
  });
</script>

<div style="font-size: 24px;">
  <p-icon library="ionicons" name="alarm"></p-icon>
  <p-icon library="ionicons" name="american-football"></p-icon>
  <p-icon library="ionicons" name="bug"></p-icon>
  <p-icon library="ionicons" name="chatbubble"></p-icon>
  <p-icon library="ionicons" name="settings"></p-icon>
  <p-icon library="ionicons" name="warning"></p-icon>
  <br />
  <p-icon library="ionicons" name="alarm-outline"></p-icon>
  <p-icon library="ionicons" name="american-football-outline"></p-icon>
  <p-icon library="ionicons" name="bug-outline"></p-icon>
  <p-icon library="ionicons" name="chatbubble-outline"></p-icon>
  <p-icon library="ionicons" name="settings-outline"></p-icon>
  <p-icon library="ionicons" name="warning-outline"></p-icon>
  <br />
  <p-icon library="ionicons" name="alarm-sharp"></p-icon>
  <p-icon library="ionicons" name="american-football-sharp"></p-icon>
  <p-icon library="ionicons" name="bug-sharp"></p-icon>
  <p-icon library="ionicons" name="chatbubble-sharp"></p-icon>
  <p-icon library="ionicons" name="settings-sharp"></p-icon>
  <p-icon library="ionicons" name="warning-sharp"></p-icon>
</div>

Jam Icons

This will register the Jam Icons library using the jsDelivr CDN. This library has two variations: regular (default) and filled (*-f). A mutator function is required to set the SVG’s fill to currentColor.

Icons in this library are licensed under the MIT License.


<script type="module">
  import { registerIconLibrary } from '/dist/utilities/icon-library.js';

  registerIconLibrary('jam', {
    resolver: name => `https://cdn.jsdelivr.net/npm/jam-icons@2.0.0/svg/${name}.svg`,
    mutator: svg => svg.setAttribute('fill', 'currentColor')
  });
</script>

<div style="font-size: 24px;">
  <p-icon library="jam" name="calendar"></p-icon>
  <p-icon library="jam" name="camera"></p-icon>
  <p-icon library="jam" name="filter"></p-icon>
  <p-icon library="jam" name="leaf"></p-icon>
  <p-icon library="jam" name="picture"></p-icon>
  <p-icon library="jam" name="set-square"></p-icon>
  <br />
  <p-icon library="jam" name="calendar-f"></p-icon>
  <p-icon library="jam" name="camera-f"></p-icon>
  <p-icon library="jam" name="filter-f"></p-icon>
  <p-icon library="jam" name="leaf-f"></p-icon>
  <p-icon library="jam" name="picture-f"></p-icon>
  <p-icon library="jam" name="set-square-f"></p-icon>
</div>

Material Icons

This will register the Material Icons library using the jsDelivr CDN. This library has three variations: outline (default), round (*_round), and sharp (*_sharp). A mutator function is required to set the SVG’s fill to currentColor.

Icons in this library are licensed under the Apache 2.0 License.



<script type="module">
  import { registerIconLibrary } from '/dist/utilities/icon-library.js';

  registerIconLibrary('material', {
    resolver: name => {
      const match = name.match(/^(.*?)(_(round|sharp))?$/);
      return `https://cdn.jsdelivr.net/npm/@material-icons/svg@1.0.5/svg/${match[1]}/${match[3] || 'outline'}.svg`;
    },
    mutator: svg => svg.setAttribute('fill', 'currentColor')
  });
</script>

<div style="font-size: 24px;">
  <p-icon library="material" name="notifications"></p-icon>
  <p-icon library="material" name="email"></p-icon>
  <p-icon library="material" name="delete"></p-icon>
  <p-icon library="material" name="volume_up"></p-icon>
  <p-icon library="material" name="settings"></p-icon>
  <p-icon library="material" name="shopping_basket"></p-icon>
  <br />
  <p-icon library="material" name="notifications_round"></p-icon>
  <p-icon library="material" name="email_round"></p-icon>
  <p-icon library="material" name="delete_round"></p-icon>
  <p-icon library="material" name="volume_up_round"></p-icon>
  <p-icon library="material" name="settings_round"></p-icon>
  <p-icon library="material" name="shopping_basket_round"></p-icon>
  <br />
  <p-icon library="material" name="notifications_sharp"></p-icon>
  <p-icon library="material" name="email_sharp"></p-icon>
  <p-icon library="material" name="delete_sharp"></p-icon>
  <p-icon library="material" name="volume_up_sharp"></p-icon>
  <p-icon library="material" name="settings_sharp"></p-icon>
  <p-icon library="material" name="shopping_basket_sharp"></p-icon>
</div>

Remix Icon

This will register the Remix Icon library using the jsDelivr CDN. This library groups icons by categories, so the name must include the category and icon separated by a slash, as well as the -line or -fill suffix as needed. A mutator function is required to set the SVG’s fill to currentColor.

Icons in this library are licensed under the Apache 2.0 License.


<script type="module">
  import { registerIconLibrary } from '/dist/utilities/icon-library.js';

  registerIconLibrary('remixicon', {
    resolver: name => {
      const match = name.match(/^(.*?)\/(.*?)?$/);
      match[1] = match[1].charAt(0).toUpperCase() + match[1].slice(1);
      return `https://cdn.jsdelivr.net/npm/remixicon@2.5.0/icons/${match[1]}/${match[2]}.svg`;
    },
    mutator: svg => svg.setAttribute('fill', 'currentColor')
  });
</script>

<div style="font-size: 24px;">
  <p-icon library="remixicon" name="business/cloud-line"></p-icon>
  <p-icon library="remixicon" name="design/brush-line"></p-icon>
  <p-icon library="remixicon" name="business/pie-chart-line"></p-icon>
  <p-icon library="remixicon" name="development/bug-line"></p-icon>
  <p-icon library="remixicon" name="media/image-line"></p-icon>
  <p-icon library="remixicon" name="system/alert-line"></p-icon>
  <br />
  <p-icon library="remixicon" name="business/cloud-fill"></p-icon>
  <p-icon library="remixicon" name="design/brush-fill"></p-icon>
  <p-icon library="remixicon" name="business/pie-chart-fill"></p-icon>
  <p-icon library="remixicon" name="development/bug-fill"></p-icon>
  <p-icon library="remixicon" name="media/image-fill"></p-icon>
  <p-icon library="remixicon" name="system/alert-fill"></p-icon>
</div>

Tabler Icons

This will register the Tabler Icons library using the jsDelivr CDN. This library features over 1,950 open source icons.

Icons in this library are licensed under the MIT License.


<script type="module">
  import { registerIconLibrary } from '/dist/utilities/icon-library.js';

  registerIconLibrary('tabler', {
    resolver: name => `https://cdn.jsdelivr.net/npm/@tabler/icons@1.68.0/icons/${name}.svg`
  });
</script>

<div style="font-size: 24px;">
  <p-icon library="tabler" name="alert-triangle"></p-icon>
  <p-icon library="tabler" name="arrow-back"></p-icon>
  <p-icon library="tabler" name="at"></p-icon>
  <p-icon library="tabler" name="ball-baseball"></p-icon>
  <p-icon library="tabler" name="cake"></p-icon>
  <p-icon library="tabler" name="files"></p-icon>
  <br />
  <p-icon library="tabler" name="keyboard"></p-icon>
  <p-icon library="tabler" name="moon"></p-icon>
  <p-icon library="tabler" name="pig"></p-icon>
  <p-icon library="tabler" name="printer"></p-icon>
  <p-icon library="tabler" name="ship"></p-icon>
  <p-icon library="tabler" name="toilet-paper"></p-icon>
</div>

Unicons

This will register the Unicons library using the jsDelivr CDN. This library has two variations: line (default) and solid (*-s). A mutator function is required to set the SVG’s fill to currentColor.

Icons in this library are licensed under the Apache 2.0 License. Some of the icons that appear on the Unicons website, particularly many of the solid variations, require a license and are therefore not available in the CDN.


<script type="module">
  import { registerIconLibrary } from '/dist/utilities/icon-library.js';

  registerIconLibrary('unicons', {
    resolver: name => {
      const match = name.match(/^(.*?)(-s)?$/);
      return `https://cdn.jsdelivr.net/npm/@iconscout/unicons@3.0.3/svg/${match[2] === '-s' ? 'solid' : 'line'}/${
        match[1]
      }.svg`;
    },
    mutator: svg => svg.setAttribute('fill', 'currentColor')
  });
</script>

<div style="font-size: 24px;">
  <p-icon library="unicons" name="clock"></p-icon>
  <p-icon library="unicons" name="graph-bar"></p-icon>
  <p-icon library="unicons" name="padlock"></p-icon>
  <p-icon library="unicons" name="polygon"></p-icon>
  <p-icon library="unicons" name="rocket"></p-icon>
  <p-icon library="unicons" name="star"></p-icon>
  <br />
  <p-icon library="unicons" name="clock-s"></p-icon>
  <p-icon library="unicons" name="graph-bar-s"></p-icon>
  <p-icon library="unicons" name="padlock-s"></p-icon>
  <p-icon library="unicons" name="polygon-s"></p-icon>
  <p-icon library="unicons" name="rocket-s"></p-icon>
  <p-icon library="unicons" name="star-s"></p-icon>
</div>

Customizing the Default Library

The default icon library contains over 1,300 icons courtesy of the Bootstrap Icons project. These are the icons that display when you use <p-icon> without the library attribute. If you prefer to have these icons resolve elsewhere or to a different icon library, register an icon library using the default name and a custom resolver.

This example will load the same set of icons from the jsDelivr CDN instead of your local assets folder.

<script type="module">
  import { registerIconLibrary } from "/dist/utilities/icon-library.js";

  registerIconLibrary("default", {
    resolver: name => `https://cdn.jsdelivr.net/npm/bootstrap-icons@1.0.0/icons/${name}.svg`,
  });
</script>

Customize the default library to use SVG sprites

To improve performance you can use a SVG sprites to avoid multiple trips for each SVG. The browser will load the sprite sheet once and then you reference the particular SVG within the sprite sheet using hash selector.

As always, make sure to benchmark these changes. When using HTTP/2, it may in fact be more bandwidth-friendly to use multiple small requests instead of 1 large sprite sheet.

<script type="module">
  import { registerIconLibrary } from '/dist/utilities/icon-library.js';

  registerIconLibrary('sprite', {
    resolver: name => `/assets/images/sprite.svg#${name}`,
    mutator: svg => svg.setAttribute('fill', 'currentColor'),
    spriteSheet: true
  });
</script>

<div style="font-size: 24px;">
  <p-icon library="sprite" name="clock"></p-icon>
  <p-icon library="sprite" name="speedometer"></p-icon>
</div>

Customizing the System Library

The system library contains only the icons used internally by Pure UI components. Unlike the default icon library, the system library does not rely on physical assets. Instead, its icons are hard-coded as data URIs into the resolver to ensure their availability.

If you want to change the icons Pure UI uses internally, you can register an icon library using the system name and a custom resolver. If you choose to do this, it’s your responsibility to provide all of the icons that are required by components. You can reference src/components/library.system.ts for a complete list of system icons used by Pure UI.

<script type="module">
  import { registerIconLibrary } from "/dist/utilities/icon-library.js";

  registerIconLibrary("system", {
    resolver: name => `/path/to/custom/icons/${name}.svg`,
  });
</script>

Importing

If you’re using the autoloader or the traditional loader, you can ignore this section. Otherwise, feel free to use any of the following snippets to cherry pick this component.

Script Import Bundler React

To import this component from the CDN using a script tag:

<script type="module" src="https://cdn.jsdelivr.net/npm/pure-uikit@1.3.13/cdn/components/icon/icon.js"></script>

To import this component from the CDN using a JavaScript import:

import 'https://cdn.jsdelivr.net/npm/pure-uikit@1.3.13/cdn/components/icon/icon.js';

To import this component using a bundler:

import 'pure-uikit/dist/components/icon/icon.js';

To import this component as a React component:

import PIcon from 'pure-uikit/dist/react/icon';

Properties

Name Description Reflects Type Default
name The name of the icon to draw. Available names depend on the icon library being used. string | undefined -
src An external URL of an SVG file. Be sure you trust the content you are including, as it will be executed as code and can result in XSS attacks. string | undefined -
label An alternate description to use for assistive devices. If omitted, the icon will be considered presentational and ignored by assistive devices. string ""
library The name of a registered custom icon library. string "default"
updateComplete A read-only promise that resolves when the component has finished updating.

Learn more about attributes and properties.

Events

Name React Event Description Event Detail
p-load onPLoad Emitted when the icon has loaded. When using spriteSheet: true this will not emit. -
p-error onPError Emitted when the icon fails to load due to an error. When using spriteSheet: true this will not emit. -

Learn more about events.

Parts

Name Description
svg The internal SVG element.
use The element generated when using spriteSheet: true

Learn more about customizing CSS parts.