Praveen Juge

Written on · 4 min read

How Niram turns a shadcn preset into a Figma design system

What happens between pasting a shadcn/ui preset code and getting native Figma variables, styles, components, and blocks, and the Figma limits I had to design around.

Niram takes a shadcn/ui preset code and builds a full design system in Figma. Variables, text styles, effects, 56 component sections, and app blocks.

I wrote about why I built it when it launched. This one is about how it works. Niram means “colour” in Tamil, so colour is where most of the work went.

The Niram page in Figma: component sections, charts, buttons, and form blocks generated from one purple preset

A preset is just a short code

When you build a theme at ui.shadcn.com/create, all your choices fit in one short code: the base (Radix or Base UI), the style, the base colour, the theme colour, the radius, and the fonts.

Niram has its own copy of shadcn’s preset decoder. It reads both the old and new code formats and rejects anything that doesn’t decode cleanly.

Then a local resolver rebuilds the same theme shadcn would, without fetching anything. Niram has no network access at all. No analytics either. It only writes to the file you run it in.

Colours as aliases, not hex codes

This is the part I cared about most.

shadcn themes are written in OKLCH. Figma variables want sRGB. So the first step is converting every colour.

But converting isn’t enough. If primary becomes a raw hex value, you lose the link to Tailwind. You can’t tell it’s blue-600 anymore.

So Niram builds the full Tailwind palette as variables first, then matches every theme colour back to it. When primary matches blue-600, the variable becomes an alias to blue-600, not a copy of its value. Change the palette and the theme follows, the same way it does in code.

One exception: colours with partial alpha, like oklch(1 0 0 / 10%). Figma aliases can’t carry an alpha override, so aliasing that to white would quietly drop the transparency. Those stay literal.

The Design System region: light and dark theme colours, the Tailwind palette, border radius, border widths, shadows, and blur

Light and dark on every plan

Real light and dark variable modes need a paid Figma plan. I didn’t want Niram to only work for teams.

So there are two ways to build the theme:

If you pick modes and the file can’t add a mode, Niram falls back to twins instead of failing halfway.

One page, because free files get three

Figma’s free plan allows three pages per file. My first version used three pages: Design System, Components, and Blocks. That took up the whole file.

Now everything goes on a single Niram page with three regions. Each region is tagged, so when you paste a new preset, each part clears and rebuilds only its own region. Your own frames on that page are left alone.

You can also replace just part of it, like only the theme. The one rule: rebuilding something upstream also rebuilds what depends on it. Blocks are made of component instances, so rebuilding components means rebuilding blocks too. Otherwise you’d get instances pointing at deleted components.

Tokens bound everywhere

Getting colours into variables is the easy half. The harder half is everything else: padding, gaps, radius, border width, font size, line height.

The builders set plain pixel values first, so the canvas looks right straight away. Then a final pass walks the whole tree and binds any value that exactly matches a token. If a gap is 16px and spacing/4 is 16px, it becomes spacing/4.

That pass is careful on purpose. It skips zeros, never overrides a binding a builder already made, and never binds width on an auto-layout frame that hugs its content, because that would quietly make it fixed.

The payoff: edit spacing/4 once and padding and gaps update across every generated component.

Components and blocks from real instances

The Components region has 56 shadcn-style sections, from buttons and inputs to data tables and overlays. Icons inside buttons are swappable instances, not flattened paths.

Blocks are built from those same components, not drawn separately:

So a change to the Button component shows up in the dashboard. That’s how it should work in Figma too.

The Blocks region: login and signup forms next to the sidebar layouts, all built from component instances

Testing a Figma plugin

Figma runs plugin code in a small JavaScript engine that doesn’t support newer syntax. Code that works fine in tests can break the moment it runs in Figma.

So the tests have three layers:

  1. Logic tests run the real generator against a fake Figma API in memory.
  2. Golden snapshots run generate twice and check the result matches, so a re-run never duplicates anything.
  3. A QuickJS sandbox builds the plugin exactly like production and runs it end to end inside a real QuickJS engine. If modern syntax slips through, it fails there and not in your file.

What I learned

Making the variables wasn’t the hard part. Keeping them in sync was.

Running it twice without duplicates. Updating in place without breaking instances. Staying inside free-plan limits. Most of Niram’s code is about re-runs, not the first run.

If you use shadcn in code and Figma for design, try Niram. The code is on GitHub. Tell me which preset breaks it.