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

@grace-studio/graceful-figma

v2.0.1

Published

[![npm version](https://badge.fury.io/js/@grace-studio%2Fgraceful-figma.svg)](https://badge.fury.io/js/@grace-studio%2Fgraceful-figma)

Downloads

74

Readme

@grace-studio/graceful-figma

npm version

✨ Graceful Figma

A CLI tool for extracting React icon components directly from Figma designs, with automatic TypeScript types and Next.js-compatible dynamic imports.


📦 Installation

npm install -D @grace-studio/graceful-figma
# or
yarn add -D @grace-studio/graceful-figma

🚀 Quick Start

graceful-figma react-icons

🛠️ Configuration

Add a .gracefulrc.json file to your project root:

{
  "token": "optional-figma-access-token",
  "react-icons": {
    "out": "./src/icons",
    "force": true,
    "sources": [
      {
        "alias": "GracefulIcons",
        "fileKey": "abc123",
        "pageName": "Icons",
        "sectionName": ["Primary", "Secondary"]
      },
      {
        "fileKey": "def456",
        "pageName": "UI",
        "sectionName": "Buttons"
      }
    ]
  }
}

🔑 Figma Access Token

Two options:

  • Recommended (via .env file):
FIGMA_ACCESS_TOKEN=your-secret-token
  • Or inline in config:
{
  "token": "your-secret-token",
  ...
}

✅ What Gets Generated?

After running:

graceful-figma react-icons

You get:

1. ✅ Pure React SVG Components (CurrentColor, Typed)

Each icon becomes a plain React functional component exporting a <svg> element.

Key characteristics:

  • No external dependencies (just React + SVG)
  • Color inherits via currentColor
  • Typed with SVGProps<SVGSVGElement> for full prop control

Example generated file: MyIcon.tsx

import type { SVGProps } from "react";

const MyIcon = (props: SVGProps<SVGSVGElement>) => (
  <svg
    xmlns="http://www.w3.org/2000/svg"
    width={32}
    height={32}
    fill="currentColor"
    viewBox="0 0 32 32"
    {...props}
  >
    <path d="..." />
  </svg>
);

export default MyIcon;

2. ✅ Tree-Structured Dynamic Import File (Next.js Compatible)

An automatically generated icons object with Next.js dynamic() imports, mirroring your Figma structure.

Example structure:

import dynamic from "next/dynamic";

const Icons = {
  Graceful: {
    Icons: {
      MyIcon: dynamic(() => import("./icon-pack/icons/icons/MyIcon")),
      ...
    },
  },
  Configuratoricons: {
    Misc: {
      AnotherIcon: dynamic(() => import("./configurator/icons/misc/AnotherIcon")),
      ...
    },
  },
};

export default Icons;

3. ✅ Type-Safe Icon Name Types (Auto-Generated)

A TypeScript utility type for type-safe icon name strings, based on the import tree:

type IconName =
  | "Graceful.Icons.MyIcon"
  | "Configuratoricons.Misc.AnotherIcon"
  | ...;

4. ✅ Ready-to-Use <IconByName /> Component

A utility component for rendering icons by name string, with full TypeScript autocomplete and type checking:

import IconByName from "./src/icons/IconByName";

<IconByName name="Graceful.Icons.MyIcon" />

✅ Autocomplete
✅ Type-safe
✅ Optional SVG props (width, className, etc.)


🧪 Example Workflow

  1. Prepare your Figma file
  2. Configure .gracefulrc.json
  3. Run:
graceful-figma react-icons
  1. Import and use anywhere in your app:
import IconByName from "./src/icons/IconByName";

export function MyButton() {
  return <IconByName name="Configuratoricons.Misc.AnotherIcon" />;
}

⚠️ Troubleshooting

| Issue | Solution | |---|---| | Missing Access Token | Set your token in .env or config file | | Invalid file key | Double-check your Figma URL | | Empty icon output | Verify pageName and sectionName | | Next.js build errors | Ensure you're using dynamic imports and not SSR for icons |


✅ Features Summary

  • ✅ Extracts React SVG icons from Figma
  • ✅ Outputs pure <svg> React components with currentColor fill
  • ✅ Generates TypeScript types for icon names
  • ✅ Provides a typed <IconByName /> lookup component
  • ✅ Outputs Next.js-optimized dynamic import trees
  • ✅ Supports .env token management
  • ✅ Supports multiple Figma files/sections

📄 License

MIT