Docs
Everything about using, styling and extending the icons. Each icon's own examples and code are in the collection.
Install
One package, every style. three.js comes with it and is only bundled when you use a WebGL model.
npm i @interactive-icons/iconsBrowse every icon, with live examples and copyable code, in the collection.
React
Every icon is a typed component, named after the icon and its style.
import { HeartFluent, MapPinClay, Search, RocketModel } from '@interactive-icons/icons/react';
<HeartFluent size={48} active={liked} onChange={(e) => setLiked(e.detail.active)} label="Like" />
<MapPinClay href="/stores" label="Find a store" />
<Search strokeWidth={1.5} />
<RocketModel trigger="loop" />| Style | Component | Element |
|---|---|---|
| Line | Heart | <ii-heart> |
| Liquid Glass | HeartGlass | <ii-heart-glass> |
| Fluent 3D | HeartFluent | <ii-heart-fluent> |
| Clay 3D | HeartClay | <ii-heart-3d> |
| WebGL model | HeartModel | <ii-heart-gl> |
- Typed per icon. Each component has its own props and docs. Toggle icons take
activeandonChange;strokeWidthis line-only,glassGlass-only,rendererfor Glass, Fluent and models. - Everything is a prop:
size,accent,speed,trigger,triggerTarget,motion,label,loopDelay,tilt,href,target,rel,download, plusclassName,style,aria-*and DOM events.onStart,onEndandonChangeget the icon's event. - Only what you import is bundled.
{ HeartFluent }is about 18 KB gzipped (React not included). Each component also has its own path:@interactive-icons/icons/react/heart-fluent. - The
refis the icon element (ref.current.play()). The firstactiveapplies without animating; later changes animate. - Server rendering works (Next.js, Remix…): components render the element and come alive on hydration. React 18 and 19.
HTML and <ii-icon>
One import registers <ii-icon>. Each icon loads the first time it appears, so a page ships only what it shows.
<script type="module">
import '@interactive-icons/icons';
</script>
<ii-icon name="map-pin"></ii-icon>
<ii-icon name="heart" variant="glass" size="64" href="/likes" label="Likes"></ii-icon>
<ii-icon name="bell" variant="fluent" trigger="loop"></ii-icon>Hover them.
| variant | Style | Same as |
|---|---|---|
line (default) | Line | <ii-heart> |
glass | Liquid Glass | <ii-heart-glass> |
fluent | Fluent 3D | <ii-heart-fluent> |
clay or 3d | Clay 3D | <ii-heart-3d> |
model or gl | WebGL model | <ii-heart-gl> |
Every other attribute goes straight to the icon. Changing name or variant swaps the icon in place. <ii-icon> forwards the API (play(), toggle(), active), and has ready (a promise of the icon) and icon. The entry is 2.7 KB gzipped: it holds only the icon names, and each style's loaders arrive with its first icon.
Importing icons directly
For full control of the bundle, import single icons or whole sets and use their own tags. Importing a module registers its elements.
| Set | Whole set | One icon | Element |
|---|---|---|---|
| Line | @interactive-icons/icons/icons | @interactive-icons/icons/icons/heart | <ii-heart> |
| Liquid Glass | @interactive-icons/icons/glass | @interactive-icons/icons/glass/heart | <ii-heart-glass> |
| Fluent 3D | @interactive-icons/icons/fluent | @interactive-icons/icons/fluent/heart | <ii-heart-fluent> |
| Clay 3D | @interactive-icons/icons/3d | @interactive-icons/icons/3d/heart | <ii-heart-3d> |
| WebGL models | @interactive-icons/icons/gl | @interactive-icons/icons/gl/rocket | <ii-rocket-gl> |
// Just the icons you use: the smallest bundle.
import '@interactive-icons/icons/icons/map-pin';
import '@interactive-icons/icons/glass/heart';
// A whole set.
import '@interactive-icons/icons/fluent';Set entries also export their classes and a list, e.g. import { glassIcons, HeartGlassIcon } from '@interactive-icons/icons/glass'. Authoring helpers (createIcon, easings…) are in @interactive-icons/icons/core.
Without a bundler
The package is plain ES modules, so it loads from a CDN. WebGL models also need three.js mapped:
<script type="importmap">
{ "imports": {
"three": "https://cdn.jsdelivr.net/npm/three@0.186.1/build/three.module.js",
"three/addons/": "https://cdn.jsdelivr.net/npm/three@0.186.1/examples/jsm/"
} }
</script>
<script type="module" src="https://cdn.jsdelivr.net/npm/@interactive-icons/icons"></script>
<ii-icon name="bell" variant="glass"></ii-icon>Triggers
One-shot icons play on hover, toggles switch on click. Change it with trigger; combine values with spaces (trigger="hover click").
| trigger | Plays when… | Try it |
|---|---|---|
hover | the pointer enters, or the control gets keyboard focus | |
click | clicked (toggles flip state) | |
load | it is added to the page | |
inview | it scrolls into view | |
loop | continuously, paused off-screen (loop-delay sets the gap) | |
manual | only when you call play() |
Inside a button, link, label or [role=button], an icon listens to that control: hovering anywhere on the button plays it. Choose the element yourself with trigger-target: self, parent, or a selector matched against ancestors (trigger-target=".card").
<button><ii-trash></ii-trash> Delete</button>Scrolling content under a still pointer doesn't count as hovering, so icons don't fire as they slide past.
Links and buttons
On its own, an icon is its own control, so you never need a wrapper:
<!-- A link: focusable, opens on click or Enter, Ctrl/⌘-click opens a new tab. -->
<ii-icon name="map-pin" variant="clay" href="/stores" label="Find a store"></ii-icon>
<!-- A button: a toggle (or trigger="click") gets role="button",
Enter and Space, and aria-pressed. -->
<ii-icon name="heart" label="Like"></ii-icon>href works with target, rel, download, referrerpolicy, hreflang and ping, as on <a>. Without a label, title or the icon's own title names the control. A role or tabindex you set is kept.
Toggle icons
Heart, menu, lock, play/pause, theme, checkbox… have two states. active (attribute or property) holds the state; changing it animates.
Click them.
const menu = document.querySelector('ii-menu');
menu.addEventListener('ii-change', (e) => setMenuOpen(e.detail.active));
menu.active = true; // animates hamburger → crossInside a <button>, a toggle keeps the button's aria-pressed in sync.
Attributes
| Attribute | Default | Description |
|---|---|---|
size | 24 | Width and height. A number is px; any CSS length works (2em). |
stroke-width | 2 | Line weight (line icons). |
accent | per icon | Colour for fills, materials and effects. |
speed | 1 | Animation speed. 2 is twice as fast. |
trigger | per icon | See Triggers. |
trigger-target | auto | auto, self, parent or a CSS selector. |
active | absent | State of a toggle icon. |
motion | auto | auto follows the OS reduced-motion setting; reduce disables animation; full always animates. |
label | none | Accessible name. Without it the icon is decorative, unless it is a link or button. |
href | none | Makes the icon a link (see Links and buttons). |
loop-delay | 600 | Pause between repeats with trigger="loop", in ms. |
tilt | on for 3D | Lean toward the pointer. tilt="off" disables it; a bare tilt enables it on line icons. |
glass | regular | Glass only: regular or clear (see Liquid Glass). |
renderer | auto | Glass, Fluent, models: svg draws the clay twin, webgl insists on WebGL. |
Styling
Line icons draw in currentColor, so they take the surrounding text colour. CSS custom properties and parts do the rest:
ii-heart {
color: slategray; /* outline */
--ii-accent: hotpink; /* fill and confetti */
--ii-size: 32px;
--ii-stroke-width: 1.5;
}
ii-map-pin::part(svg) { filter: drop-shadow(0 1px 1px rgb(0 0 0 / 0.2)); }JavaScript API and events
const bell = document.querySelector('ii-bell');
await bell.play(); // resolves when it finishes (no restart if already playing)
bell.restart(); // plays again from the start
bell.stop(); // cancels the animation
bell.playing; // true while animating
bell.speed = 1.5;
heart.toggle(); // toggles: flip state (or toggle(true / false))
heart.active; // current state| Event | detail | Fired when |
|---|---|---|
ii-start | { active } | an animation starts |
ii-end | { active } | an animation finishes (not when stopped) |
ii-change | { active } | a toggle changes by click or toggle() |
Events bubble and cross shadow boundaries.
Five styles
All 260 icons come in Line, Liquid Glass and Fluent 3D. 41 of them are also hand-made as Clay 3D icons and WebGL models; the collection shows which styles each icon comes in, and iconNames from @interactive-icons/icons/names lists them in code.
WebGL models are in the collection (Models tab).
- Line: crisp outlines in the text colour.
- Liquid Glass: one fused piece of glass that frosts the page behind it.
- Fluent 3D: soft, matte, rounded forms with gentle gradients.
- Clay 3D: glossy SVG with lighting, depth and soft shadows; tilts toward the cursor.
- WebGL models: detailed three.js models with physically based materials.
Clay 3D
- Pointer tilt with parallax between parts.
tilt="off"disables it; it is skipped for touch and reduced motion. - Colour: the main material is
accent/--ii-accent; some icons have a second material in--ii-accent-2(the pin's ball, the gift's ribbon). Shading is mixed from those automatically. - Best at 40px and up. Shading uses
color-mix()(Chrome/Edge 111+, Safari 16.2+, Firefox 113+).
<ii-heart-3d accent="#8b5cf6" size="72"></ii-heart-3d>
<ii-settings-3d style="--ii-accent: #64748b; --ii-accent-2: #22c55e"></ii-settings-3d>Liquid Glass
All strokes and fills fuse into one glass slab: a clear face, a bevelled edge that catches the light, glints, a caustic and a soft shadow. It follows Apple's Liquid Glass guidance:
- It blurs what's behind it, masked to the glyph and following the animation.
- Two variants:
glass="regular"(default) frosts and brightens;glass="clear"is highly translucent for rich backgrounds. - It reacts: the light follows the pointer; a press lights the glass and springs it back.
- It adapts to dark pages, Increase contrast, Reduce transparency and Reduce motion.
Glass takes its colour from what is behind it; style the frost with ::part(frost).
Fluent 3D and how 3D icons move
Glass and Fluent are generated from the line icons. A hidden copy of the line icon plays its own animation, and every frame its transforms, opacity and stroke drawing are mirrored onto the 3D parts, so the pin drops and the bell swings in 3D, with the same triggers, toggles and events.
accent recolours the main hue; parts the line icon draws in its accent colour follow --ii-accent-2. A Glass or Fluent icon costs 18–22 KB gzipped, with no three.js.
WebGL models
- Real materials: lacquered plastic and polished metal reflecting a studio environment.
- One renderer per page: browsers allow about 16 WebGL contexts, so icons share a hidden renderer and copy frames out. Any number of icons work; frames are drawn only while something moves.
- Fallback: without a hardware GPU, Glass, Fluent and models show their clay twin (
<ii-bell-glass>shows<ii-bell-3d>).renderer="svg"picks the twin yourself. - Room to move: the canvas overhangs the icon by 25% so bounces aren't clipped.
Rendering and the GPU
Icons check the machine once, when the browser is idle, and adapt:
| Hardware GPU | Software rendering only | |
|---|---|---|
| Glass, Fluent, models | WebGL, multisampled, up to 2× resolution on capable GPUs | Their clay SVG twins |
| Line and clay animations | On the GPU compositor, off the main thread | On the compositor where supported |
- Off the main thread: Chrome, Edge and Firefox composite SVG animations themselves. On Safari and iOS, icons lift moving parts onto their own layers for the animation, only where the result is pixel-identical.
- Adaptive resolution: if canvas animations keep missing frames, resolution steps down (never below 1×).
- Nothing blocks the page: canvas icons build in the background (
await icon.ready).
import { configure, gpu } from '@interactive-icons/icons/core';
gpu(); // { hardware: true, tier: 'high', renderer: 'Apple M2' }
configure({ renderer: 'svg' }); // never WebGL ('webgl' always tries; default 'auto')
configure({ layers: 'on' }); // always lift moving parts ('off' never; default 'auto')Add ?perf to this site's address to see where frame time goes on your device.
Bundle size
Minified and gzipped. The shared runtime is counted once, so each extra icon costs well under 1 KB.
| Import | Gzipped |
|---|---|
@interactive-icons/icons (<ii-icon>, before any icon loads) | 2.7 KB |
| One line icon | 7.7 KB |
| All 260 line icons | 45 KB |
| One clay icon | 8.3 KB |
| One Fluent icon | 17.8 KB |
| One Glass icon | 22.1 KB |
| One React component | 18.9 KB + React |
| One WebGL model | 15 KB + three.js (~145 KB) |
three.js installs with the package but is only bundled for the models: other imports carry none of it, and <ii-icon> loads it on demand for variant="gl". The tests enforce every budget.
Accessibility
- Icons respect
prefers-reduced-motion(or setmotion). - Without a
label, icons are decorative and hidden from screen readers; links and buttons are named fromlabel,titleor the icon's title. - Toggles keep
aria-pressedin sync; icons used as buttons get Enter and Space.
Vue, Svelte and others
The icons are custom elements: import once, use the tag. In Vue, tell the compiler about the prefix:
// vite.config.js
vue({ template: { compilerOptions: { isCustomElement: (tag) => tag.startsWith('ii-') } } })TypeScript
Types ship with the package: every tag is in HTMLElementTagNameMap (document.querySelector('ii-heart') is an icon), ii-change listeners get a typed detail, and each icon's type documents its motion, states and default trigger. The ii-* elements are typed for JSX too.
createIcon
The helper the built-in icons use. Give it an SVG on a 24×24 grid and a motion function:
import { createIcon } from '@interactive-icons/icons/core';
createIcon({
name: 'my-rocket', // registers <ii-my-rocket>
title: 'Rocket',
description: 'Lifts off with a shake.',
hue: '#ef4444', // its colour in Glass and Fluent
svg: `<g class="ship"><path d="M12 2c4 3 5 8 3 14H9C7 10 8 5 12 2z"/></g>`,
motion(m) {
m.animate('.ship', [
{ transform: 'translate(0, 0)' },
{ transform: 'translate(0, -20px)', opacity: 0, offset: 0.6, easing: m.easing.in },
{ transform: 'translate(0, 0)', opacity: 1 },
], 1200);
m.burst({ x: 12, y: 18, count: 5, rotate: 90, spread: 90, delay: 200 });
},
});m.animate(target, keyframes, duration)runs Web Animations on matching elements; durations scale withspeed.m.draw()draws strokes withpathLength="1";m.burst(),m.ripple(),m.sparkle()add particles.m.easing:spring,springSoft,springStiff,bounce,overshoot,gravity,in,out,inOut.- For toggles pass
toggle: true;m.activeis the state being animated to. Style resting states with:host([active]). - Transforms use each element's box as origin; add class
ii-cto rotate around the grid centre.
3D, Glass and Fluent
For a clay icon pass depth: true and build from @interactive-icons/icons/core/clay: material(), solid(), gloss(), shadow(), layer(z, …) and shape helpers. Turn any icon into Glass or Fluent:
import { createLookIcon } from '@interactive-icons/icons/looks';
import { liquidGlass } from '@interactive-icons/icons/looks/glass';
import { MyRocketIcon } from './my-rocket.js';
createLookIcon(MyRocketIcon, 'fluent'); // <ii-my-rocket-fluent>
createLookIcon(MyRocketIcon, 'glass', { paint: liquidGlass }); // <ii-my-rocket-glass>WebGL models
Use createGlIcon from @interactive-icons/icons/gl: build({ root, accent }) adds three.js meshes (helpers: extrude(), lathe(), plastic(), metal()), pose() sets the resting state, and motion(m, parts) animates properties by path:
m.animate(parts.bell, [{ 'rotation.z': 0 }, { 'rotation.z': 0.4 }, { 'rotation.z': 0 }], 900);