Giter Club home page Giter Club logo

create-figma-plugin's Introduction

Create Figma Plugin npm Version build

A comprehensive toolkit for developing Figma plugins

Features

Quick start

To start, read the Figma plugin basics doc to understand how a Figma plugin actually works, and to learn about what’s currently possible (and not possible) in a Figma plugin.

Pre-requisites

Initialize a new plugin

First:

$ npx create-figma-plugin figma-hello-world --yes

Then:

$ cd figma-hello-world
$ ls -a
.gitignore  README.md  node_modules  package-lock.json  package.json  tsconfig.json  src
$ ls src
main.ts

src/main.ts is the main entry point for our plugin:

// src/main.ts

export default function () {
  figma.closePlugin('Hello, World!')
}

See that in package.json, we’re pointing to src/main.ts on the "main" key under "figma-plugin":

  {
    ...
    "figma-plugin": {
      ...
      "name": "Hello World",
+     "main": "src/main.ts"
    }
  }

(This example only scratches the surface of what this toolkit provides. See the recipes section below, or jump to the ones for adding a UI to a plugin command, or specifying multiple commands in the plugin sub-menu.)

Build the plugin

In package.json, we also have build and watch scripts set up to invoke the build-figma-plugin CLI:

  {
    ...
    "scripts": {
+     "build": "build-figma-plugin",
+     "watch": "build-figma-plugin --watch"
    },
    ...
  }

To build the plugin:

$ npm run build

This will generate a manifest.json file and a build/ directory containing a JavaScript bundle for the plugin.

To watch for code changes and rebuild the plugin automatically:

$ npm run watch

Installing the plugin

In the Figma desktop app:

  1. Open a Figma document.
  2. Go to PluginsDevelopmentNew Plugin….
  3. Click the Click to choose a manifest.json file box, and select the manifest.json file that was generated.

Debugging

Use console.log statements to inspect values in your code.

To open the developer console in the Figma desktop app, go to PluginsDevelopmentOpen Console.

Docs

Recipes

See also

Prior art

Create Figma Plugin’s configuration API is heavily inspired by skpm’s.

License

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.