Install
SIDEARM Icons are published to AWS codeartifact, but they can also be manually downloaded if needed.
npm
Install SIDEARM Icons—including SVGs, icon sprite, and icon fonts—with npm. Then, choose how you’d like to include the icons with the usage instructions.
npm run aws:login
npm i @sidearm/sidearm-icons
CDN
Include the icon fonts stylesheet—in your website <head>
or via @import
in CSS—from our CDN and get started in seconds. See icon font docs for examples.
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/sidearm-icons@0.1.0/font/sidearm-icons.css">
@import url("https://cdn.jsdelivr.net/npm/sidearm-icons@0.1.0/font/sidearm-icons.css");
Usage
SIDEARM 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="32" height="32" fill="currentColor" class="s-icon s-icon-sports-football" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M13.667 3.267a1.32 1.32 0 0 0-.934-.934A10.582 10.582 0 0 0 10.2 2L14 5.8c0-1.067-.2-1.933-.333-2.533ZM2.333 12.733c.134.467.467.8.934.934C3.8 13.8 4.733 14 5.8 14L2 10.2c0 1.067.2 1.933.333 2.533Zm-.2-4.066 5.2 5.266c3.2-.466 6-2.866 6.6-6.533L8.667 2.067c-3.2.466-6 2.933-6.534 6.6Zm7.667-3a.203.203 0 0 1 .267 0l.266.266c.067.067.067.2 0 .267l-.666.667.666.666c.067.067.067.2 0 .267l-.266.267a.203.203 0 0 1-.267 0L9.133 7.4l-.6.6.667.667c.067.066.067.2 0 .266l-.267.267a.203.203 0 0 1-.266 0L8 8.533l-.533.534.666.666c.067.067.067.2 0 .267l-.266.267a.203.203 0 0 1-.267 0L6.933 9.6l-.666.667a.203.203 0 0 1-.267 0L5.733 10a.203.203 0 0 1 0-.267l.667-.666-.667-.667a.203.203 0 0 1 0-.267L6 7.867a.203.203 0 0 1 .267 0l.666.666L7.467 8 6.8 7.333a.203.203 0 0 1 0-.266l.267-.267a.203.203 0 0 1 .266 0L8 7.467l.533-.534-.666-.666a.203.203 0 0 1 0-.267l.266-.267a.203.203 0 0 1 .267 0l.667.667.733-.733Z"/>
</svg>
Icon Component
Internally you can use the Design system component library to use icons in your project.
<s-icon name="icon-sport-football"></s-icon>
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="s-icon s-icon-sport-football" width="32" height="32" fill="currentColor">
<use xlink:href="sidearm-icons-sports.svg#icon-sport-football"/>
</svg>
<svg class="s-icon s-icon-sport-soccer" width="32" height="32" fill="currentColor">
<use xlink:href="sidearm-icons-sports.svg#icon-sport-soccer"/>
</svg>
<svg class="s-icon s-icon-sport-baseball" width="32" height="32" fill="currentColor">
<use xlink:href="sidearm-icons-sports.svg#icon-sport-baseball"/>
</svg>
External image
Copy the SIDEARM Icons SVGs to your directory of choice and reference them like normal images with the <img>
element.
<img src="/assets/img/icon-sport-football.svg" alt="Football Icon" width="32" height="32">
Icon font
Icon fonts with classes for every icon are also included for SIDEARM Icons. Include the icon web fonts in your page via CSS, then reference the class names as needed in your HTML (e.g., <span class="sf-sports sf-icon-sport-football"></span>
).
Use font-size
and color
to change the icon appearance.
<span class="sf-sports sf-icon-sport-football"></span>
<span class="sf-sports sf-icon-sport-football" style="font-size: 2rem; color: brown;"></span>
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.
.s-icon::before {
display: inline-block;
content: "";
vertical-align: -.125em;
background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32' fill='%23333' class='s-icon s-icon-sidearm' viewBox='0 0 16 16'>
<path d='M8.067 16a.605.605 0 0 1-.467-.2l-2.466-2.533c-.134-.134-.2-.4-.2-.6 0-.2.2-.4.4-.467l5.133-2.4a.709.709 0 0 1 .8.133l1 1.134a.8.8 0 0 1 0 .933L8.6 15.8c-.2.133-.4.2-.533.2Zm-1.4-3L8 14.4l2.734-2.867-.267-.266L6.667 13ZM4.4 11.733a.605.605 0 0 1-.466-.2L.8 8.467C.667 8.333.534 8.2.6 8c.067-.2.067-.333.2-.467l1.934-1.866a.644.644 0 0 1 .933 0l1.467 1.4 6.2-2.8c.266-.134.533-.067.733.133L15.2 7.467c.134.133.2.266.2.466s-.066.334-.2.467l-1.933 1.867a.645.645 0 0 1-.933 0l-1.467-1.4-6.2 2.8c-.133.066-.2.066-.267.066ZM2.2 8l2.334 2.267L10.6 7.6a.605.605 0 0 1 .467-.2c.2 0 .333.067.467.2l1.333 1.267 1-.934-2.333-2.266-6.2 2.733c-.067.067-.2.067-.267.067h-.133a.605.605 0 0 1-.467-.2L3.2 7.067 2.2 8Zm3.134-1.733a.605.605 0 0 1-.467-.2L3.734 4.933a.8.8 0 0 1 0-.933L7.4.2a.72.72 0 0 1 .467-.2c.2 0 .333.067.467.2l2.533 2.533c.133.134.2.4.2.6-.067.2-.2.4-.4.467L5.6 6.2c-.133.067-.2.067-.266.067Zm-.2-1.8.333.333L9.334 3l-1.4-1.4-2.8 2.867Z'/>
</svg>");
background-repeat: no-repeat;
background-size: 1rem 1rem;
}
Styling
Color can be changed by setting a .text-*
class or custom CSS:
<svg class="s-icon s-icon-sport-football 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:
<!-- alt="..." on <img> element -->
<img src="/assets/img/icon-sport-football.svg" alt="Football Logo" ...>
<span class="sf-sports sf-icon-sport-football" role="img" aria-label="Football Logo"></span>
<svg class="s-icon" ... role="img" aria-label="Football Logo">
<use xlink:href="sidearm-icons-sports.svg#icon-sport-football"/>
</svg>
<!-- aria-label="..." on the control -->
<button ... aria-label="Mute">
<svg class="s-icon s-icon-sport-football" 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.
-
External SVG sprites may not function correctly in Internet Explorer. Use the svg4everybody polyfill as needed.
Found another issue with SVGs we should note? Please open an issue to share details.