Early-bird pricing is open: 50 of 50 licenses still available. See pricing

Skip to content
popcons

React

Props, PopconsProvider and the play/stop ref for Popcons icons in React.

Every icon is a React component with the same props. React 18 or newer is required.

import { HeartIcon } from "@popcons/react";

<HeartIcon size={32} color="#6D5EF8" strokeWidth={2} trigger="hover" label="Like" />

Props

Props
PropTypeDefaultDescription
sizenumber24Width and height in pixels.
colorstringcurrentColorStroke colour. Defaults to the surrounding text colour.
strokeWidthnumber2Stroke width on the 24px grid.
corner"round" | "sharp""round"Line caps and joins.
speednumber1Speed multiplier. 2 is twice as fast.
intensitynumber1Motion amplitude multiplier. 0 is static.
trigger"hover" | "click" | "loop" | "in-view" | "none""hover"What starts the animation. Hover also fires on focus of the icon or its closest button or link.
labelstringnoneAccessible name. Without it the icon is decorative and hidden from assistive technology.
mirrorInRtlbooleantrue for directional iconsFlips arrows, send, undo, redo, share and similar icons horizontally inside dir="rtl" layouts. Set false to opt out.

PopconsProvider

Set defaults for every icon below it, including reduced-motion behaviour.

import { PopconsProvider } from "@popcons/react";

<PopconsProvider size={20} strokeWidth={1.75} speed={1.2} reducedMotion="respect">
  <App />
</PopconsProvider>

reducedMotion accepts respect (follow the OS setting, the default), always (animate regardless; use only for previews the user started) and never-animate. Props on an icon override the provider.

Play and stop from a ref

import { useRef } from "react";
import { BellIcon, type IconHandle } from "@popcons/react";

export function Demo() {
  const bell = useRef<IconHandle>(null);
  return (
    <>
      <BellIcon ref={bell} trigger="none" size={32} />
      <button onClick={() => bell.current?.play()}>Ring</button>
      <button onClick={() => bell.current?.stop()}>Stop</button>
    </>
  );
}

The handle also exposes element, the underlying SVG. Calling play() still respects the reduced-motion mode.

Accessibility

Icons next to a text label should stay decorative. Icons alone inside a button need a name on the button, or a label on the icon. See accessibility.