Jiggicons

JavaScript

jiggicons: toSvg(), play() and the <jigg-icon> element.

The jiggicons package is what the React and Vue packages are built on. It has no dependencies and gives you four things: icon data, functions to draw and play icons, a custom element, and the CLI.

npm install jiggicons

Draw and play

import { toSvg, play } from 'jiggicons';
import bell from 'jiggicons/icons/bell';

const button = document.querySelector('#notify');
button.insertAdjacentHTML('afterbegin', toSvg(bell, { variant: 'solid', size: 20 }));
button.addEventListener('click', () => play(button, bell, { sound: true }));
Function
toSvg(icon, options)An <svg> string: variant, size, title, className, uid (unique ids when one icon appears twice)
markupOf(icon, variant, uid)Only the inside of the <svg>, for your own wrapper
play(root, icon, options)Plays the icon drawn inside root: variant, sound, volume. Returns a stop function.
stop(root)Stops it and returns it to rest
bindTrigger(element, animate, run)Wires hover, click or mount to run; returns a cleanup function
playSound(icon, options)Only the sound
setVolume(value)Volume for every icon sound, 0 to 1

The <jigg-icon> element

import { define, register } from 'jiggicons/element';
import bell from 'jiggicons/icons/bell';
import heart from 'jiggicons/icons/heart';

register(bell, heart);
define();
HTML
<jigg-icon name="bell" variant="solid" sound></jigg-icon>
<jigg-icon name="heart" animate="click" label="Like"></jigg-icon>

Attributes: name, variant, size, animate, sound, volume and label. The element draws into the page, not a shadow root, so your CSS and color reach it.

Icon data

Each icon is a plain object: { id, name, category, svg: { outline, solid, duotone, glass }, motion }. Each svg entry holds the markup for that variant. The same markup is the still icon and the moving one, because each moving part is a group that rests in place. jiggicons/icons exports all 80 free icons, and jiggicons/icons.json lists them.