Back to Plugins
fig2tw - Convert variables to Tailwind, CSS or JSON

fig2tw - Convert variables to Tailwind, CSS or JSON

Convert variables into a Tailwind plugin, CSS or JSON

tailwindcsscsstailwindvariablesscopejson

Plugin Preview

fig2tw - Convert variables to Tailwind, CSS or JSON preview

About this plugin

Convert Figma variables into a Tailwind plugin, CSS or JSON file.


Key features:

Tailwind configuration is inferred from the variable scopes.

Configure the variable scopes in Figma to generate useful Tailwind configuration.

<div class="bg-primary text-on-primary rounded-sm gap-md p-xs">
The background color is given by the variable "color/primary".
The text color is given by the variable "color/on primary".
The border-radius is given by the variable "radius/sm".
The gap is given by the variable "space/md".
The padding is given by the variable "space/xs".
</div>


All variable modes are converted into CSS variables.

Change the mode (light, dark, etc.) with a CSS class.

<div class="theme-light">Figma's light mode variables are applied here</div>
<div class="theme-dark">Figma's dark mode variables are applied here.</div>


Number units are configured by variable scope.

Define how numbers are to converted to CSS. You can choose from px, em, rem. Font weights don't have units.


Getting started:

1. Download the generated Tailwind plugin

Download the tailwind plugin using the "Download" button and place the file next to your tailwind.config.ts.


2. Import the generated plugin in your Tailwind configuration

In the tailwind.config.ts file, import the generated plugin and place it in the plugins array. The configuration should look like below.

import fig2tw from "tailwind.fig2tw";
const config = {
plugins: [fig2tw],
// ...
}
export default config;


Supports:

Tailwind configuration scopes:

colors, fill, accentColor, backgroundColor, gradientColorStops, borderColor, stroke, ringColor, ringOffsetColor, outlineColor, textColor, textDecorationColor, caretColor, placeholderColor, boxShadowColor.

spacing, size, width, minWidth, maxWidth, height, minHeight, maxHeight, margin, inset, borderRadius, padding, gap, space, scrollMargin, scrollPadding, borderSpacing, strokeWidth, outlineWidth, borderWidth, ringWidth, fontFamily, fontSize, lineHeight, letterSpacing, fontWeight


Figma variables scopes:

ALL_SCOPES, ALL_FILLS, FRAME_FILL, SHAPE_FILL, TEXT_FILL, STROKE_COLOR, EFFECT_COLOR, CORNER_RADIUS, WIDTH_HEIGHT, GAP, STROKE_FLOAT, FONT_SIZE, LINE_HEIGHT, LETTER_SPACING, FONT_WEIGHT, FONT_FAMILY

Plugin Details

Version6
CreatedMay 25, 2024
Last UpdatedFebruary 16, 2025
CategorySoftware development
CreatorLaurent O'Donoughue
Stats20 installs, 6 likes
PricingFree

Technical Details

  • API:1.0.0
  • UI:./index.html
  • main:./main.js
  • Document Access:dynamic-page
  • Editor Types:
    figma
  • Allowed Domains:
    • https://api-js.mixpanel.com
    • https://fonts.gstatic.com