iconly
Version:
Iconly is designed to load and cache SVG icons in the browser, using IndexedDB to store the data. It retrieves the icons from a given SVG file, stores them in IndexedDB, and inserts them into the DOM for easy access and use.
74 lines (55 loc) • 2.44 kB
Markdown
<div align="center">
<br>
<h1>iconly</h1>
<p><sup>Iconly is designed to load and cache SVG icons in the browser, using IndexedDB to store the data. It retrieves the icons from a given SVG file, stores them in IndexedDB, and inserts them into the DOM for easy access and use.</sup></p>
[](https://www.npmjs.com/package/iconly)
[](https://github.com/ux-ui-pro/iconly)
[](https://www.npmjs.org/package/iconly)
<sup>1.5kB gzipped</sup>
<a href="https://codepen.io/ux-ui/pen/zYmyqWR">Demo</a>
</div>
<br>
&
```console
$ yarn add iconly
```
<br>
&
```javascript
import Iconly from 'iconly';
```
<br>
&
```javascript
const iconly = new Iconly({
file: './sprite.svg',
version: '1.0',
debug: true,
});
iconly.init().then(() => console.log('Iconly is initialized and icons are loaded.'));
```
```HTML
<svg>
<use href="#icon-name"></use>
</svg>
```
<sub>File with icons</sub>
```HTML
<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none" fill="none">
<symbol id="icon-name" viewBox="0 0 300 300">
<path ... />
</symbol>
...
</svg>
```
<br>
&
| Option | Type | Default | Description |
|:-----------:|:-----------------------:|:---------------:|:--------------------------------------------------------------------------------------------------------|
| `file` | `string` | `'./icons.svg'` | The URL of the SVG file containing the icons. |
| `version` | `string` | `'1.0'` | The version of the icon set. |
| `debug` | `boolean` | `false` | If `true`, debug information and errors will be logged to the console. |
| `container` | `string \| HTMLElement` | `document.body` | The container element where the icons will be injected. Can be a CSS selector string or an HTMLElement. |
<br>
&
iconly is released under MIT license