Skip to main content

When-I-Work Icons

pnpm add @wiw/icons@latest

Currently v7.2.16 Repo

Filter Icons

How to use WIW font icon library

Usage

WIW Icons are SVGs, so you can include them into your HTML in a few ways depending on how your project is setup. We recommend using a width: 1em (and optionally height: 1em) for easy resizing via font-size.

Embedded

Embed your icons within the HTML of your page (as opposed to an external image file). Here we’ve used a custom width and height.

<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="wiw-icon wiw-emoji-heart-eyes" viewBox="0 0 16 16"><path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/><path d="M11.315 10.014a.5.5 0 0 1 .548.736A4.498 4.498 0 0 1 7.965 13a4.498 4.498 0 0 1-3.898-2.25.5.5 0 0 1 .548-.736h.005l.017.005.067.015.252.055c.215.046.515.108.857.169.693.124 1.522.242 2.152.242.63 0 1.46-.118 2.152-.242a26.58 26.58 0 0 0 1.109-.224l.067-.015.017-.004.005-.002zM4.756 4.566c.763-1.424 4.02-.12.952 3.434-4.496-1.596-2.35-4.298-.952-3.434zm6.488 0c1.398-.864 3.544 1.838-.952 3.434-3.067-3.554.19-4.858.952-3.434z"/></svg>

Sprite

Use the SVG sprite to insert any icon through the <use> element. Use the icon’s filename as the fragment identifier (e.g., toggles is #toggles). SVG sprites allow you to reference an external file similar to an <img> element, but with the power of currentColor for easy theming.

Heads up! There’s an issue with Chrome where <use> doesn’t work across domains.

  <svg class="wiw" width="32" height="32" fill="currentColor">
    <use xlink:href="wiw-icons.svg#heart-filled"/>
  </svg>
  <svg class="wiw" width="32" height="32" fill="currentColor">
    <use xlink:href="wiw-icons.svg#help"/>
  </svg>
  <svg class="wiw" width="32" height="32" fill="currentColor">
    <use xlink:href="wiw-icons.svg#microphone"/>
  </svg>
  

External image

Copy the WIW Icons SVGs to your directory of choice and reference them like normal images with the <img> element.

When I Work Icon
<img src="assets/img/wiw-icon.svg" alt="When I Work Icon" width="32" height="32">

Icon font

Icon fonts with classes for every icon are also included for WIW Icons. Include the icon web fonts in your page via CSS, then reference the class names as needed in your HTML (e.g., <i class="wiw-alarm-clock"></i>).

Use font-size and color to change the icon appearance.

<i class="wiw-date"></i>
<i class="wiw-date" style="font-size: 2rem; color: cornflowerblue;"></i>

CSS

You can also use the SVG within your CSS (be sure to escape any characters, such as # to %23 when specifying hex color values). When no dimensions are specified via width and height on the <svg>, the icon will fill the available space.

The viewBox attribute is required if you wish to resize icons with background-size. Note that the xmlns attribute is required.

.wiw-icon::before {
  display: inline-block;
  content: "";
  vertical-align: -.125em;
  background-image: url("data:image/svg+xml,<svg viewBox='0 0 16 16' fill='%23333' xmlns='http://www.w3.org/2000/svg'><path fill-rule='evenodd' d='M8 9.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3z' clip-rule='evenodd'/></svg>");
  background-repeat: no-repeat;
  background-size: 1rem 1rem;
}

Styling

Color can be changed by setting a .text-* class or custom CSS:

<svg class="wiw-icon wiw-exclamation-triangle text-success" width="32" height="32" fill="currentColor" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
  ...
</svg>

Accessibility

For purely decorative icons, add aria-hidden="true". Otherwise, provide an appropriate text alternative. Depending on which method you’re using to add the icons, and where you’re using them (e.g. as standalone images, or as the only content of a button or similar control), there are various possible approaches. Here are a few examples:

<i class="wiw-github" role="img" aria-label="GitHub"></i>
<svg class="wiw-icon" ... role="img" aria-label="Tools">
  <use xlink:href="wiw-icons.svg#tools"/>
</svg>
<!-- aria-label="..." on the control -->
<button ... aria-label="Mute">
  <svg class="wiw-icon wiw-volume-mute-fill" aria-hidden="true" ...>
  ...
  </svg>
</button>

Working with SVGs

SVGs are awesome to work with, but they do have some known quirks to work around. Given the numerous ways in which SVGs can be used, we haven’t included these attributes and workarounds in our code.

Known issues include:

  • SVGs receive focus by default in Internet Explorer and Edge Legacy. When embedding your SVGs, add focusable="false" to the <svg> element. Learn more on Stack Overflow.

  • When using SVGs with <img> elements, screen readers may not announce them as images, or skip the image completely. Include an additional role="img" on the <img> element to avoid any issues. See this article for details.