Jiggicons

React

jiggicons-react: components with motion and sound.

npm install jiggicons-react
Notifications.jsx
import { Bell } from 'jiggicons-react';

export function Notifications({ count }) {
  return (
    <button className="notifications">
      <Bell variant="solid" sound />
      {count} new
    </button>
  );
}

Every free icon is a named export in PascalCase: Bell, MusicNote2, WeatherMoon. Unused icons are left out of your bundle.

Props

PropDefault
variant'outline'outline, solid, duotone or glass. Styles
size24Width and height in pixels (or any CSS length as a string)
animate'hover'What plays it: hover (also keyboard focus), click, mount or none. When icons play
soundfalsePlay the icon’s spatial sound with its motion. Sound
volume1Sound volume from 0 to 1
title—Accessible name. Leave it out when the icon sits next to a visible label. Accessibility

Every other prop (className, style, onClick, data-*…) goes to the <svg>.

Play from code

A ref gives you play() and stop():

import { useRef } from 'react';
import { Gift } from 'jiggicons-react';

export function Reward() {
  const gift = useRef(null);
  return <>
    <Gift ref={gift} animate="none" size={40} />
    <button onClick={() => gift.current.play()}>Open</button>
  </>;
}

Icons from the full set

npx jiggicons add shopping-bag writes a component made with createJiggicon, which takes the same props:

import { ShoppingBag } from '@/components/jiggicons';

<ShoppingBag variant="glass" animate="click" sound />

To pick an icon at run time, pass its data to Jiggicon:

import { Jiggicon } from 'jiggicons-react';
import bell from 'jiggicons/icons/bell';

<Jiggicon icon={bell} variant="duotone" />

Server rendering

The still icon renders on the server as plain SVG, so it is in the HTML from the first paint. Motion and sound load with the component in the browser. The package marks itself 'use client', so you can use the icons in Server Components without wrapping them. See Next.js.