This repo demonstrates how to fetch design tokens, specifically colors, from a Figma file and generate theme files in JavaScript format.
- Node.js
- Yarn
- Figma API Access Token
-
Clone the repository:
git clone <repository-url> cd <repository-directory>
-
Install the dependencies:
yarn
-
Set your Figma Access Token & File ID:
-
Create a
.env
file in the root of the project. -
Add the following content to the
.env
file:FIGMA_ACCESS_TOKEN=<your-figma-access-token> FIGMA_FILE_ID=<your-figma-file-id>
Replace
<your-figma-access-token>
with your Figma access token and<your-figma-file-id>
with the Figma file ID you want to fetch colors from.To get the Figma file ID, open the Figma file in the browser and copy the file ID from the URL. The file ID is the last part of the URL after the
/file/
path.For example, if the Figma file URL is
https://www.figma.com/file/abc123/My-Design-File
, the file ID isabc123
. -
To run the script and generate the theme files, use the following command:
yarn start