npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@reforma/icons

v0.2.0

Published

Icon library for Reforma design system

Readme

@reforma/icons

React/TypeScript icon library for the Reforma design system. The package automatically discovers icon packs from the src/ directory and generates optimized components with full TypeScript support.

Overview

This package provides a flexible icon system that:

  • Automatically discovers icon packs from subdirectories in src/ (e.g., src/12, src/14, src/16, src/custom-pack)
  • Optimizes SVG files by removing fill attributes, Figma artifacts (like clip-path), and unnecessary elements
  • Supports both SVG and PNG icons (PNG files are copied as-is without optimization)
  • Generates React components for each icon with proper TypeScript types
  • Provides base styles for consistent icon rendering with currentColor inheritance
  • Offers strict TypeScript typing that ensures icon names match their respective packs

Usage

Basic Usage

import { Icon } from '@reforma/icons';
import '@reforma/icons/styles.css'; // Import base styles

// Using the Icon component with pack specification
<Icon pack="16" name="add" className="text-primary" title="Add item" />

// Without pack (uses default pack '16')
<Icon name="close" />

Direct Icon Import

You can also import individual icons directly:

import { AddIcon } from '@reforma/icons/16';
import { CloseIcon } from '@reforma/icons/14';

<AddIcon className="text-primary" title="Add" />
<CloseIcon size={20} />

Package Structure

packages/icons/
├── src/
│   ├── [pack]/            # Source of truth - place your SVG/PNG files here (e.g., 12/, 14/, 16/)
│   ├── icons-metadata.json # Icon metadata configuration
│   └── styles.css         # Base icon styles
├── dist/                  # Built output
│   ├── [pack]/            # Generated React components per pack
│   └── index.ts           # Main entry point
└── scripts/
    └── build.js           # Build script that generates components

Commands

Run from packages/icons:

  • bun run build — Generates React components from SVG files in src/ and builds the package
  • bun run sync — Synchronizes every icon pack from Figma
  • bun run sync 14 — Synchronizes only the exact 14 pack
  • bun run sync --list — Lists available Figma packs without changing local files
  • bun run sync auth — Replaces and verifies the saved Figma token without synchronizing files
  • bun run typecheck — Type checks the package

Run from the repository root:

  • ./reforma sync icons — Synchronizes every icon pack from the configured Figma frame
  • ./reforma sync icons 14 — Synchronizes only the 14 pack
  • ./reforma sync icons --list — Lists exact pack names, node IDs, and icon counts without exporting or writing
  • ./reforma sync icons --list --json — Returns the versioned pack list for scripts and AI agents
  • ./reforma sync icons auth — Replaces and verifies the saved token without synchronizing files

The node-specific URL of the root Figma frame is stored in icons-metadata.json:

{
    "figma": {
        "excludeFromSyncSuffix": "~",
        "iconsSourceUrl": "https://www.figma.com/design/FILE_KEY/FILE_NAME?node-id=1-2"
    }
}

Run ./reforma sync icons auth and follow the authorization steps printed in the terminal:

  1. In the opened Figma settings, select Security.
  2. Under Personal access tokens, click Generate new token.
  3. Set Name to Reforma icons.
  4. Set Expiration to 90 days.
  5. Under Scopes, select Files → file_content:read.
  6. Generate and copy the token, then paste it into the hidden terminal prompt.

The command verifies access to the configured Figma file and stores the token outside the repository in ~/.config/reforma/figma-access-token with user-only (0600) permissions. Later runs reuse it. When Figma rejects an expired token, the command asks for a replacement. FIGMA_ACCESS_TOKEN remains available as a non-interactive CI override. A non-interactive run without a token fails with AUTH_REQUIRED; an agent must ask the developer to run ./reforma sync icons auth in their own terminal and must never request the token in chat.

During synchronization, the command shows the current phase and progress for pack comparison, SVG export, downloading, local file updates, and package build. --json reserves stdout for one versioned result, including addedFiles, changedFiles, and removedFiles; progress is written to stderr. Machine errors use stable codes including AUTH_REQUIRED, PACK_NOT_FOUND, INVALID_FIGMA_STRUCTURE, and FIGMA_REQUEST_FAILED.

The root frame's direct auto-layout children are packs. Each pack frame name becomes the source directory name, its text heading is ignored, and it must contain exactly one direct component set. A variant property such as name=color is exported to color.svg. To bypass optimization for a new icon, use the configured suffix in Figma too: with excludeFromOptimizationSuffix: ".", name=google. becomes google..svg. The same suffix on a pack applies this behavior to every icon: logo. synchronizes into src/logo, while its SVG files retain their original colors and structure. A pack ending with figma.excludeFromSyncSuffix is excluded from synchronization entirely; with the configured ~, private~ is not listed, exported, or validated.

The generated src/figma-icons-manifest.json stores a fingerprint per Figma component. Subsequent runs export only new, renamed, visually changed, or locally modified vector icons. Variants that contain component instances are conservatively re-exported because their master can change outside the variant subtree. A full sync also removes previously managed icons and packs that no longer exist in Figma; a selected sync changes only the requested packs, and pre-existing files absent from the manifest are never removed. The package build runs only after managed source files changed.

What Happens During Build

When you run bun run build, the following happens:

  1. Clean — Removes dist/ and .turbo/ directories
  2. Process Icons — Processes icons from src/:
    • SVG files: Optimized with SVGO to:
      • Remove fill attributes (icons inherit currentColor)
      • Remove width and height attributes (keeps viewBox for flexibility)
      • Remove Figma artifacts (clip-path attributes, empty <defs>, <clipPath> elements)
      • Clean up unnecessary attributes and elements
    • PNG files: Copied as-is (no optimization)
  3. Generate Components — Creates:
    • React components for each icon (one per file)
    • Index files for each pack (barrel exports)
    • Main index.ts that exports all packs
    • Updates package.json exports for each pack
  4. Copy Assets — Copies styles.css to dist/

Adding New Icons

Step-by-Step Guide

  1. Prepare your icons:

    • Export SVG or PNG files from Figma (or any design tool)
    • Ensure file names match the desired icon names (e.g., user-add.svg, settings.svg)
  2. Place icons in the correct pack directory:

    • Each subdirectory in src/ represents an icon pack
    • Pack names can be numeric (e.g., 12, 14, 16) or custom strings (e.g., custom-pack)
    • Example: To add an icon to pack 16, place it in src/16/my-icon.svg
  3. Run the build command:

    cd packages/icons
    bun run build
  4. Verify the results:

    • Check dist/[pack]/ to see generated components
    • TypeScript types will be automatically updated

Rules for Adding Icons

  • Icon name = file name: The icon name is derived from the file name (without extension)
    • user-add.svg → icon name "user-add"
    • settings.png → icon name "settings"
  • Skip optimization: Add the suffix configured in icons-metadata.json to the source filename. With optimization.excludeFromOptimizationSuffix: ".", google..svg skips SVGO and still exports as Google.
  • Pattern exclusions: packs[pack].excludeFromOptimization remains available for glob-based or pack-wide exclusions.
  • File format: Supported formats are .svg and .png
  • Naming convention: Use kebab-case for file names (e.g., user-add.svg, not userAdd.svg)

SVG Requirements

For best results, SVG files should:

  • Use currentColor for fills/strokes (or no fill attribute, which will be removed during optimization)
  • Have a viewBox attribute (width/height will be removed)
  • Not contain hard-coded colors
  • Have transparent backgrounds (no raster data)

The optimization process will:

  • ✅ Remove fill attributes (ensures currentColor inheritance)
  • ✅ Remove width and height attributes
  • ✅ Remove Figma artifacts (clip-path, empty <defs>, <clipPath>)
  • ✅ Clean up unnecessary attributes
  • ✅ Preserve viewBox for flexible sizing

Styles

The package includes base styles in styles.css that ensure icons inherit currentColor by default. Import them in your application:

// In your main CSS file (e.g., globals.css)
import '@reforma/icons/styles.css';

The styles ensure:

  • Icons inherit currentColor from their parent
  • SVG and IMG elements properly handle sizing
  • Consistent rendering across different icon types

TypeScript Types

The package provides the following types:

  • IconPack — Union type of all pack names
  • IconName — Union type of all icon names across all packs
  • IconCollection — Object type mapping packs to their icon names:
    type IconCollection = {
      'pack1': 'close' | 'code' | ...;
      'pack2': 'H' | 'W' | ...;
      'pack3': 'add' | 'arrow-left' | ...;
    };
  • IconSize — Union type of numeric pack sizes (for backward compatibility)
  • IconComponent — Type for individual icon components

Accessibility

The Icon component handles accessibility automatically:

  • With title prop: Renders role="img" and aria-label with the title, plus a <title> element inside SVG
  • Without title prop: Renders aria-hidden="true" to hide from assistive technologies

Fallback Behavior

If an icon is not found in the specified pack, the Icon component returns null. There is no automatic fallback to other packs — TypeScript will catch these errors at compile time when using strict typing.