# Icon
A web component for displaying icons.
```js script
import { html } from '@lion/core';
import { icons } from './index.js';
import './docs/icons/iconset-bugs.js';
import './docs/icons/iconset-misc.js';
import * as spaceSet from './docs/icons/iconset-space.js';
import './lion-icon.js';
export default {
title: 'Icons/Icon',
};
icons.addIconResolver('lion', (iconset, name) => {
switch (iconset) {
case 'bugs':
return import('./docs/icons/iconset-bugs.js').then(module => module[name]);
case 'space':
return import('./docs/icons/iconset-space.js').then(module => module[name]);
case 'misc':
return import('./docs/icons/iconset-misc.js').then(module => module[name]);
default:
throw new Error(`Unknown iconset ${iconset}`);
}
});
```
```js preview-story
export const main = () => html`
`;
```
## How to use
### Installation
```bash
npm i --save @lion/icon
```
```js
import { LionIcon } from '@lion/icon';
// or
import '@lion/icon/lion-icon.js';
```
### Icon sets
Icons are displayed using icon sets. These are collections of icons, lazily loaded on demand for performance.
See the [system documentation](?path=/docs/icons-system--page) to learn more about icon sets.
```js preview-story
export const iconSets = () => html`
${Object.keys(spaceSet).map(
name => html`
${name}
`,
)}
`;
```
If for some reason you don't want to lazy load icons, you can still import and use them
synchronously.
### Accessibility
It is recommended to add an `aria-label` to provide information to visually impaired users:
A `lion-icon` without an `aria-label` attribute will be automatically given an `aria-hidden` attribute.
```js preview-story
export const accessibleLabel = () => html`
`;
```
### Styling
By default, a `lion-icon` will be `1em` × `1em` (the current line-height).
`lion-icon` uses SVGs and may be styled with CSS, including using CSS properties such as `fill`:
```js preview-story
export const Styling = () => html`
`;
```
See SVG and CSS on MDN web docs for more information.