To create a new page in Figma using Typescript, you will need to first create a new Figma plugin project in Typescript. Here are the steps you can follow:
index.ts47 chars2 lines
This will create a new plugin project with Typescript support.
src
folder of your new project, create a new file named create-page.ts
. This file will contain the logic to create a new page in Figma. Add the following code to the file:index.ts179 chars8 lines
This code imports the createPage
function from the figma-plugin-ds
library and uses it to create a new page. The ID of the newly created page is logged to the console.
main.ts
file in the src
folder and import the createPage
function from the create-page.ts
file:index.ts44 chars2 lines
run
function with a call to the createPage
function:index.ts47 chars4 lines
index.ts14 chars2 lines
This will start a development server for your plugin.
Plugins
> Development
> My Plugin
from the menu bar. A new page should be created in your Figma file with a randomly generated name.Note: In order to create a new page, your plugin will need to have the can-create-page
capability set in the manifest.json
file. You can add this capability by adding the following line to the capabilities
array in the manifest:
index.ts22 chars2 lines
And that's it! You should now have a working Figma plugin that can create new pages in Typescript.
gistlibby LogSnag