0.42.0 • Published 9 days ago

@spectrum-web-components/icons-ui v0.42.0

Weekly downloads
886
License
Apache-2.0
Repository
github
Last release
9 days ago

Description

Deliver Spectrum UI Icons as either:

  • Registered custom elements (<sp-icon-arrow75>)
  • Unregistered class definitions (IconArrow75)
  • Functions with customizable template tags to be used across various frameworks (Arrow75Icon())

Search a full list of icons to find an icon for your project or find technical information about extended use cases, like consuming this package in various UI frameworks below.

Remember to consult Spectrum's Iconography Guidelines when planning how to leverage these icons in the visual delivery of your application.

Usage

See it on NPM! How big is this package in your project?

yarn add @spectrum-web-components/icons-ui

Import the side effectful registration of a single element (e.g. <sp-icon-arrow75>) via:

import '@spectrum-web-components/icons-ui/icons/sp-icon-arrow75.js';

Leverage a single icon base class (e.g. IconArrow75) as a type, or for extension purposes, do so, via:

import { IconArrow75 } from '@spectrum-web-components/icons-ui/src/elements/IconArrow75.js';

Find an icon

Search the available Spectrum Workflow icons below.

Alternative usage

You can import raw icons (e.g. Arrow75Icon()) via:

import { Arrow75Icon } from '@spectrum-web-components/icons-ui/src/icons/Arrow75.js';

@spectrum-web-components/icons-ui exports all icons. If your build process tree-shakes dependencies, you can import from it directly:

import { Arrow75Icon } from '@spectrum-web-components/icons-ui';

These icon literals are prepared with the html template tag from lit-html, the default value of an icon export will be as follows:

import { LitElement, html } from 'lit-element';
import '@spectrum-web-components/icon';
import { Arrow75Icon } from '@spectrum-web-components/icons-ui';

class ElementWithIcon extends LitElement {
    protected override render(): TemplateResult {
        return html`
            <sp-icon>
                ${Arrow75Icon()}
            </sp-icon>
        `
    }
}

customElements.define('element-with-icon', ElementWithIcon);

Every icons can be customized via the following options:

{
    width: 24, // number outlining the width to deliver the SVG element with
    height: 24, // number outlining the height to delivery the SVG element with
    hidden: false, // boolean representing whether to apply the `aria-hidden` attribute
    title: 'Icon title', // string of the title to deliver the icon with
}

Extended use cases

The default exports of this package are pre-wrapped via setCustomTemplateLiteralTag in the html template tag from lit-html, and work like the following::

import { Arrow75Icon } from '@spectrum-web-components/icons-ui';

console.log(Arrow75Icon());

/***
TemplateResult {strings: Array[1], values: Array[0], type: "html", processor: DefaultTemplateProcessor, constructor: Object}
***/

When working in the context of other frameworks, it is possible to import the icons with a generic template tag as follows:

import { Arrow75Icon } from '@spectrum-web-components/icons-ui/src/icons.js';

console.log(Arrow75Icon());

/***
<svg
    xmlns="http://www.w3.org/2000/svg"
    viewBox="0 0 36 36"
    role="img"
    fill="currentColor"
    height="24"
    width="24"
    aria-hidden="false"
    aria-label="Circle"
>
    <path
      d="M9.26 4.406L6.528 1.672A.84.84 0 005.34 2.859L6.64 4.16H1.396a.84.84 0 000 1.68H6.64l-1.301 1.3a.84.84 0 001.188 1.188l2.734-2.734a.84.84 0 000-1.188z"
    />
</svg>
***/

What's more, if you're already working with a specific parser in your project, you can assign it as the one to use when delivering the icons in order to be sure that the SVG content is delivered as parsed content to your final template. The means if you were working with Preact via the htm tag as bound to the provided hyperscript function:

import {
    Arrow75Icon,
    setCustomTemplateLiteralTag,
} from '@spectrum-web-components/icons-ui/src/icons.js';
import htm from 'htm';
import { h } from 'preact';

const hPreact = htm.bind(h);

setCustomTemplateLiteralTag(hPreact);

console.log(Arrow75Icon());

/***
VNode {nodeName: "svg", children: Array[1], attributes: Object, key: undefined, constructor: Object}
***/

In this way the icons exported by @spectrum-web-components/icons-ui can be leveraged in projects powered by the the likes of hyperHTML, lighterhtml, lit-html, Preact, React, Vanilla JS, Vue.js, and more!

0.42.0

9 days ago

0.41.2

23 days ago

0.41.1

1 month ago

0.41.0

1 month ago

0.40.5

2 months ago

0.40.4

2 months ago

0.40.3

3 months ago

0.40.2

3 months ago

0.40.1

4 months ago

0.36.0

7 months ago

0.40.0

4 months ago

0.35.1-rc.15

8 months ago

0.37.0

7 months ago

0.34.1-rc.0

9 months ago

0.35.1-rc.25

8 months ago

0.35.1-rc.26

8 months ago

0.35.1-rc.24

8 months ago

0.38.0

7 months ago

0.35.1-rc.34

8 months ago

0.34.0

9 months ago

0.35.1-rc.43

8 months ago

0.35.1-rc.41

8 months ago

0.39.1

6 months ago

0.39.0

6 months ago

0.35.0

8 months ago

0.39.4

5 months ago

0.39.3

5 months ago

0.39.2

6 months ago

0.33.3-overlay.66

9 months ago

0.33.3-overlay.65

9 months ago

0.33.3-overlay.61

9 months ago

0.31.1-react.21

10 months ago

0.32.0

10 months ago

0.31.1-react.3

11 months ago

0.31.1-react.2

11 months ago

0.30.1-overlay.30

11 months ago

0.33.1-overlay.39

10 months ago

0.30.1-overlay.31

11 months ago

0.33.2

10 months ago

0.33.0

10 months ago

0.30.1-overlay.38

11 months ago

0.30.1-overlay.37

11 months ago

0.30.1-overlay.41

11 months ago

0.30.1-overlay.42

11 months ago

0.30.1-overlay.40

11 months ago

0.30.0

11 months ago

0.33.1-overlay.41

10 months ago

0.32.1-overlay.33

10 months ago

0.32.1-overlay.41

10 months ago

0.31.0

11 months ago

0.31.1-overlay.29

11 months ago

0.9.9

1 year ago

0.9.12

11 months ago

0.9.10

1 year ago

0.9.11

12 months ago

0.9.13-overlay.10

11 months ago

0.9.13-overlay.12

11 months ago

0.9.13-overlay.11

11 months ago

0.9.13-overlay.18

11 months ago

0.9.13-overlay.17

11 months ago

0.9.13-overlay.14

11 months ago

0.9.13-overlay.13

11 months ago

0.9.13-overlay.15

11 months ago

0.9.11-overlay.22

12 months ago

0.9.8-react.75

1 year ago

0.9.8

1 year ago

0.9.8-react.49

1 year ago

0.9.8-react.48

1 year ago

0.9.8-react.50

1 year ago

0.9.8-react.32

1 year ago

0.9.7

1 year ago

0.9.6

1 year ago

0.9.5

1 year ago

0.9.5-react.54

1 year ago

0.9.4

1 year ago

0.9.3

1 year ago

0.9.2

1 year ago

0.9.1

1 year ago

0.9.0-devmode.0

2 years ago

0.8.13-devmode.0

2 years ago

0.8.12-devmode.7

2 years ago

0.8.12-devmode.0

2 years ago

0.9.0

2 years ago

0.8.12

2 years ago

0.8.11

2 years ago

0.8.10

2 years ago

0.8.9

2 years ago

0.8.8

2 years ago

0.8.7

2 years ago

0.8.6

2 years ago

0.8.5

2 years ago

0.8.4

2 years ago

0.8.4-express.9

2 years ago

0.8.3-express.12

2 years ago

0.8.2-express.41

2 years ago

0.8.3

2 years ago

0.8.2

2 years ago

0.7.1

2 years ago

0.8.1

2 years ago

0.8.0

2 years ago

0.7.1-lit-next.0

2 years ago

0.7.0

2 years ago

0.6.11

3 years ago

0.6.10

3 years ago

0.6.10-beta.32

3 years ago

0.6.10-alpha.30

3 years ago

0.6.9

3 years ago

0.6.10-alpha.1

3 years ago

0.6.8

3 years ago

0.6.9-alpha.1

3 years ago

0.6.8-alpha.59

3 years ago

0.6.7

3 years ago

0.6.8-alpha.1

3 years ago

0.6.7-alpha.74

3 years ago

0.6.7-alpha.73

3 years ago

0.6.7-alpha.72

3 years ago

0.6.7-alpha.61

3 years ago

0.6.7-alpha.27

3 years ago

0.6.7-alpha.0

3 years ago

0.6.6

3 years ago

0.6.5-alpha.26

3 years ago

0.6.5

3 years ago

0.6.5-alpha.23

3 years ago

0.6.5-alpha.21

3 years ago

0.6.5-beta.10

3 years ago

0.6.5-beta.17

3 years ago

0.6.5-beta.16

3 years ago

0.6.5-beta.15

3 years ago

0.6.5-beta.14

3 years ago

0.6.5-beta.13

3 years ago

0.6.5-beta.12

3 years ago

0.6.5-beta.11

3 years ago

0.6.5-alpha.17

3 years ago

0.6.5-alpha.10

3 years ago

0.6.5-alpha.12

3 years ago

0.6.5-alpha.11

3 years ago

0.6.5-alpha.9

3 years ago

0.6.4

3 years ago

0.6.3

3 years ago

0.6.2

3 years ago

0.6.1

3 years ago

0.6.0

3 years ago

0.5.3-alpha.33

3 years ago

0.5.3

3 years ago

0.5.2

3 years ago

0.5.1

3 years ago

0.5.0

3 years ago

0.3.4-alpha.178

3 years ago

0.4.0-alpha.40

3 years ago

0.4.0

3 years ago

0.3.4-alpha.169

3 years ago

0.3.4-alpha.84

3 years ago

0.3.4-alpha.85

3 years ago

0.3.4-alpha.60

3 years ago

0.3.3-alpha.0

3 years ago

0.3.2

3 years ago

0.3.3

3 years ago

0.3.2-beta.17

3 years ago

0.3.2-alpha.17

3 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.2-alpha.77

4 years ago

0.2.2

4 years ago

0.2.2-alpha.34

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.3-alpha.38

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago