<sp-icon>
renders an icon to the page. By default the name
attribute will pair with separately registered icon sets to deliver the icons. When not present, <sp-icon>
will subsequently check for its src
attribute which could populate the icon via an image, and then fallback to any slotted content for an element based icon.

yarn add @spectrum-web-components/icon
Import the side effectful registration of <sp-icon>
via:
import '@spectrum-web-components/icon/sp-icon.js';
When looking to leverage the Icon
base class as a type and/or for extension purposes, do so via:
import { Icon } from '@spectrum-web-components/icon';
Names of the icons on this page are provided by the <sp-icons-medium>
icon set. Learn how to create your own via sp-iconset
.
<sp-icons-medium></sp-icons-medium>
<sp-icon name="ui:Arrow100"></sp-icon>
Icons are available in various sizes in Spectrum ranging from s
to xxl
. By default an sp-icon
without a size
attribute will appear as if it were size="m"
. We can specify the size via size
attribute.
<sp-icon size="s" name="ui:Arrow100"></sp-icon>
<sp-icon size="m" name="ui:Arrow100"></sp-icon>
<sp-icon size="l" name="ui:Arrow100"></sp-icon>
<sp-icon size="xl" name="ui:Arrow100"></sp-icon>
<sp-icon size="xxl" name="ui:Arrow100"></sp-icon>
Icons apply their color as currentColor
, so change the color
property of the element for customization.
<sp-icon name="ui:Arrow100" style="color: red;"></sp-icon>
An image icon can be supplied via the src
attribute. Remember that you cannot style the contents of an image via CSS, so use graphics that are appropriate for your application's design requirements.
<sp-icon
label="Previous"
src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9Ii0yOTU3Ljk5NSAtNTUzMC4wMzIgNiAxMCI+PGRlZnM+PHN0eWxlPi5he2ZpbGw6bm9uZTtzdHJva2U6IzE0NzNlNjtzdHJva2UtbGluZWNhcDpyb3VuZDtzdHJva2UtbGluZWpvaW46cm91bmQ7c3Ryb2tlLW1pdGVybGltaXQ6MTA7c3Ryb2tlLXdpZHRoOjJweDt9PC9zdHlsZT48L2RlZnM+PHBhdGggY2xhc3M9ImEiIGQ9Ik0yNTEuMywzMzNsNC00LTQtNCIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTI3MDEuNjk1IC01MTk2LjAzMikgcm90YXRlKDE4MCkiLz48L3N2Zz4="
></sp-icon>
Icons can also be supplied via HTML elements and are applied via the default <slot>
.
<sp-icon>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 22 22"
role="img"
fill="currentColor"
height="18"
width="18"
aria-hidden="true"
>
<path
d="M19.75,10.04h-15l5.97-5.97a.483.483,0,0,0,0-.7l-.35-.36a.513.513,0,0,0-.71,0L2.24,10.44a.513.513,0,0,0,0,.71l7.39,7.84a.513.513,0,0,0,.71,0l.35-.35a.513.513,0,0,0,0-.71L4.76,11.5H19.75a.25.25,0,0,0,.25-.25v-.96A.25.25,0,0,0,19.75,10.04Z"
></path>
</svg>
</sp-icon>
If no meaning is lost by visually hiding an icon, it is considered decorative. Decorative icons should not have a label and should be hidden from assistive technology. aria-hidden
is set to true by default for icons.
If an icon does add meaning, a label is required. Use the label
attribute to set the label's text as the aria-label
of the icon and remove the aria-hidden
attribute.
<sp-icon name="ui:Arrow100" label="Arrow pointing to the right"></sp-icon>
Changelog
- Updated dependencies []:
- @spectrum-web-components/iconset@1.4.0
- @spectrum-web-components/base@1.4.0
- Updated dependencies []:
- @spectrum-web-components/iconset@1.3.0
- @spectrum-web-components/base@1.3.0
All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.
- reactive-controllers: Migrate to Colorjs from Tinycolor (#4713) (9d740f0)
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
- lock prerelease versions for Spectrum CSS (#5014) (8aa7734)
- add an optional chromatic vrt action (7d2f840)
- toast: adds iconLabel to address accessibility (#4944) (8121057)
- icon: remove size300 suffix from chevron and checkmark icons in Spectrum 2 (#4904) (a22f42b)
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
- asset: use core tokens (99e76f4)
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
- icon: use core tokens (a11ef6b)
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
- infield-button: add infield-button package (057b885)
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
- alert-dialog: add Alert Dialog package (#3501) (1062847)
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
- action-bar: use core tokens (4e21edf)
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
- icon: image src invalid error api (19e06f9)
- icon: review comment changes (ba75d94)
- icon: review comment changes (4597713)
- icon: review comment changes (19287fb)
- icon: review comment changes (dee1929)
- icon: review comment changes (cb41b33)
- icon: skipping test case for webkit (fa4b903)
- allow "updateComplete" to resolve to a boolean like the LitElement default (6127946)
- correct @element jsDoc listing across library (c97a632)
- ensure browser understandable extensions (f4e59f7)
- icon: clean up docs and types for available size values (c38850d)
- icon: prevent async race resulting in multiple inner SVG elements (b05e2d5)
- include "type" in package.json, generate custom-elements.json (1a8d716)
- include default export in the "exports" fields (f32407d)
- include the "types" entry in package.json files (b432f59)
- manage updated node types (0517fc1)
- normalize "event" and "error" argument names (8d382cd)
- remove ":" based namespacing of events (d77a843)
- update consumption of Spectrum CSS for latest version (ed2305b)
- update latest Spectrum CSS beta releases (d8d3acc)
- update side effect listings (8160d3a)
- update to latest spectrum-css packages (a5ca19f)
- use icons without "size" values (3fc7c91)
- use latest @spectrum-css/* versions (c35eb86)
- action-button: add action button pattern (03ac00a)
- adopt DNA@7 base Spectrum CSS (e08cafd)
- icon: add UIIcon styles (6f03b1a)
- icon: allow to accept a slotted icon (cbf7a07)
- icons-workflow: vend fully registered icon components (941f3a4)
- icon: update spectrum css input (42f17db)
- include all Dev Mode files in side effects (f70817c)
- leverage "exports" field in package.json (321abd7)
- overlay: manage focus throwing and tab trapping (27a0b53)
- shared pkg versions, devmode define warning, registry-conflicts docs (6e49565)
- update lit-* dependencies, wip (377f3c8)
- update to Spectrum CSS v3.0.0 (e8b3d8f)
- use @adobe/spectrum-css@2.15.1 (3918888)
- use latest exports specification (a7ecf4b)
- use "sideEffects" listing in package.json (7271614)
- use imported TypeScript helpers instead of inlining them (cc2bd0a)
- Revert "chore: release new versions" (a6d655d)
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
- manage updated node types (0517fc1)
Note: Version bump only for package @spectrum-web-components/icon
- include all Dev Mode files in side effects (f70817c)
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
- update consumption of Spectrum CSS for latest version (ed2305b)
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
- update lit-* dependencies, wip (377f3c8)
Note: Version bump only for package @spectrum-web-components/icon
- icon: prevent async race resulting in multiple inner SVG elements (b05e2d5)
- adopt DNA@7 base Spectrum CSS (e08cafd)
Note: Version bump only for package @spectrum-web-components/icon
- correct @element jsDoc listing across library (c97a632)
- allow "updateComplete" to resolve to a boolean like the LitElement default (6127946)
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
- use latest exports specification (a7ecf4b)
- update to latest spectrum-css packages (a5ca19f)
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
- icon: clean up docs and types for available size values (c38850d)
- include the "types" entry in package.json files (b432f59)
- update latest Spectrum CSS beta releases (d8d3acc)
- use icons without "size" values (3fc7c91)
- use latest @spectrum-css/* versions (c35eb86)
- action-button: add action button pattern (03ac00a)
- icon: update spectrum css input (42f17db)
- icons-workflow: vend fully registered icon components (941f3a4)
- include the "types" entry in package.json files (b432f59)
- update latest Spectrum CSS beta releases (d8d3acc)
- use icons without "size" values (3fc7c91)
- use latest @spectrum-css/* versions (c35eb86)
- action-button: add action button pattern (03ac00a)
- icon: update spectrum css input (42f17db)
- icons-workflow: vend fully registered icon components (941f3a4)
Note: Version bump only for package @spectrum-web-components/icon
- include default export in the "exports" fields (f32407d)
- update side effect listings (8160d3a)
- update to Spectrum CSS v3.0.0 (e8b3d8f)
Note: Version bump only for package @spectrum-web-components/icon
- ensure browser understandable extensions (f4e59f7)
- overlay: manage focus throwing and tab trapping (27a0b53)
- leverage "exports" field in package.json (321abd7)
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
- use "sideEffects" listing in package.json (7271614)
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
Note: Version bump only for package @spectrum-web-components/icon
- normalize "event" and "error" argument names (8d382cd)
- include "type" in package.json, generate custom-elements.json (1a8d716)
- use @adobe/spectrum-css@2.15.1 (3918888)
- remove ":" based namespacing of events (d77a843)
- icon: allow to accept a slotted icon (cbf7a07)
- icon: add UIIcon styles (6f03b1a)
- use imported TypeScript helpers instead of inlining them (cc2bd0a)
Note: Version bump only for package @spectrum-web-components/icon