MCPcopy Index your code
hub / github.com/LekoArts/figma-theme-ui

github.com/LekoArts/figma-theme-ui @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
21 symbols 64 edges 16 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Theme UI Plugin for Figma

Convert a Theme UI config to Figma Styles.

Install the plugin

Usage

Choose a .json file that only contains your theme. Example:

{
  "fonts": {
    "body": "-apple-system, BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue',Arial,'Noto Sans',sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol','Noto Color Emoji'",
    "heading": "inherit"
  },
  "fontSizes": [12, 14, 16, 20, 24, 32],
  "fontWeights": {
    "body": 400,
    "heading": 700
  },
  "lineHeights": {
    "body": 1.5,
    "heading": 1.125
  },
  "colors": {
    "text": "rgb(0,0,0)",
    "background": "#fff",
    "brand": {
      "primary": "hsl(205, 100%, 40%)",
      "secondary": "#30c"
    },
    "teal": [null, "#e6fffa", "#b2f5ea", "#81e6d9"]
  }
}

The shape of the theme has to follow the theme specification. Otherwise the plugin can't find your styles. In your frontend code you can setup your bundler to be able to load .json files so that you can directly use it for your Theme UI config. This way the file is interchangeable.

More specifically, you'll need to bring the theme into the following shape (as shown above):

  • fonts, fontWeights and lineHeights have to have the same keys (above: body and heading)
  • fontSizes has to be defined as Array<number>
  • fontWeights and lineHeights need to have a number as property

Lastly, click "Add Styles" to create your Figma Styles.

Development

Install the dependencies:

yarn install

And build the plugin:

yarn build

Go to your "Plugins" tab inside Figma and press the "+" button on "Development". Choose the manifest.json file inside figma-theme-ui folder.

You now can open the plugin in any project. Run yarn dev to have rollup watch your changes. You'll need to re-open the plugin after every change.

Acknowledgements

  • Thanks to Figsvelte for his cool boilerplate to start a Figma plugin with Svelte
  • Thanks to tailwindcss-figma-plugin for giving me an idea on how to use Figma's API

Extension points exported contracts — how you extend this code

IThemeUIColor (Interface)
(no doc)
src/@types/core.d.ts
IOptions (Interface)
(no doc)
src/@types/core.d.ts
IMessage (Interface)
(no doc)
src/@types/core.d.ts
IFigmaFonts (Interface)
(no doc)
src/@types/core.d.ts
IConvertFonts (Interface)
(no doc)
src/@types/typography.d.ts

Core symbols most depended-on inside this repo

parseConfig
called by 7
src/core/config.ts
flattenObject
called by 5
src/core/utils.ts
findFigmaFont
called by 4
src/core/typography.ts
convertColor
called by 3
src/core/colors.ts
stringToArray
called by 3
src/core/utils.ts
convertFonts
called by 3
src/core/typography.ts
parseTypography
called by 3
src/core/typography.ts
addColors
called by 2
src/core/colors.ts

Shape

Function 16
Interface 5

Languages

TypeScript100%

Modules by API surface

src/core/typography.ts6 symbols
src/@types/core.d.ts4 symbols
src/core/utils.ts3 symbols
src/core/colors.ts3 symbols
src/core/figma.ts2 symbols
src/core/config.ts1 symbols
src/@types/typography.d.ts1 symbols
rollup.config.mjs1 symbols

For agents

$ claude mcp add figma-theme-ui \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact