Importing a Tailwind Site Into Figma and Keeping the Spacing Scale
Tailwind to Figma without losing the spacing scale: read the base unit, convert rem to px, and rebuild the steps as Figma number variables.
Introduction
When you bring a Tailwind site into Figma, the spacing values arrive as plain numbers, but the scale behind them does not. You keep it by recording the site's base unit, converting rem to px once, and rebuilding the steps as Figma number variables. This tutorial walks through that in order. You need the site's CSS open and a Figma file with the imported page in it, for example one brought in with UnHTML.
The goal is modest. Figma layers carry numeric padding and gap values, not class names like p-4. An import reads the rendered page, so the number is there and the name is gone. The steps below put the names back.
How Tailwind v4 builds its spacing scale
One variable, many utilities
As of October 2026, the Tailwind v4 documentation lists --spacing: 0.25rem in its default theme variables. Every spacing step is a multiple of that one value. The padding reference shows the compiled form: p-<number> becomes padding: calc(var(--spacing) * <number>). So p-4 is 4 times 0.25rem, which is 1rem.
That's why the scale feels regular. Step 1 is 0.25rem, step 2 is 0.5rem, and every jump between steps is the same size.
Which utilities share it
The --spacing-* namespace covers more than padding. The theme documentation describes it as driving spacing and sizing utilities like px-4 and max-h-16. Width, height, margin and gap draw from the same steps. When you read an imported frame, a 64px gap and a 64px height can come from the same step 16.
Sites that change the base
A site can redefine the base unit inside @theme. The Tailwind docs show examples such as --spacing: 4px and --spacing: 1px. If a site sets a different base, every step changes with it, and the 4px assumption no longer holds. Don't convert imported values until you've checked the source theme.
rem versus px: what the numbers mean after import
Tailwind writes its scale in rem. MDN defines rem as relative to the font-size of the root element, usually html. It also notes that 16px is a common browser default, but user preferences may change it. Figma works in px, so a conversion happens somewhere between the browser and your file.
At a 16px root, the common steps look like this:
| Tailwind step | Value in rem | Value in px |
|---|---|---|
| 1 | 0.25rem | 4px |
| 2 | 0.5rem | 8px |
| 3 | 0.75rem | 12px |
| 4 | 1rem | 16px |
| 6 | 1.5rem | 24px |
| 8 | 2rem | 32px |
| 16 | 4rem | 64px |
If the site sets html { font-size: 62.5%; } or any other root size, this table is wrong for that site. Open the CSS, find the root font size, and redo the multiplication. One number decides whether every padding in the file reads correctly.
Check the source theme before you import
Do this before you touch Figma. Five minutes here saves a day of wrong variables.
- Open the site's main stylesheet, or the source of its Tailwind entry file.
- Search for
@theme. Note any--spacingor--spacing-*lines and the value on each. - Search for a root
font-sizeonhtmlor:root. - Write down the base unit in px. For the default theme at a 16px root, that is 4px.
- Write down any named tokens, such as a custom
--spacing-18, with their px value.
A site on an older Tailwind version keeps its scale in a different place, usually a config file. Don't guess which version you're looking at. Read the actual CSS and trust the numbers in it.
Turn the scale into a Figma variable collection
Figma variables are the right home for a spacing scale. The Figma guide to variables explains that variables live in collections and that modes let one variable hold several values. A spacing collection can start with one mode and gain others later, for example a compact and a roomy density.
Here is the sequence:
- Create a collection named Spacing.
- Add number variables named by step:
space/1,space/2,space/4, and so on. - Set each value from your table:
space/1is 4,space/4is 16,space/16is 64. - Add any custom tokens you found in the theme, with their own px values.
- Select the imported frames and apply the variables to auto layout padding and gap.
To match imported values to steps, divide the px value by your base unit. A 24px padding divided by 4 is step 6. A 20px gap divided by 4 is step 5, which sits between the steps in the table but is still on the scale.
If you would rather not type the numbers, a third-party route exists. The CSS Variables community plugin lists support for px, in, cm, mm, pt, pc and rem lengths, and it converts rem using a 16px base. It is not a built-in Figma feature, and it ignores variables that are not color or length. Test it on a small file first, and confirm the collection actually appears. For a fuller picture of how variables make a page adapt, see making an imported page responsive with Figma variables.
A worked example: reading a card
Suppose you import a pricing page and select one card. Figma shows 24px padding on all sides, a 16px gap between the title and the body text, and a 32px gap between the card and the next card.
With a 4px base, the arithmetic is short. The 24px padding is step 6 (24 divided by 4). The 16px gap is step 4. The 32px gap between cards is step 8. In Tailwind terms that card was probably written as p-6, with gap-4 inside and gap-8 around it, though the import cannot tell you the original classes, only the values.
Now bind them. Select the card, open the padding fields in the auto layout panel, and attach space/6. Attach space/4 to the inner gap and space/8 to the outer one. Repeat for the next card and you will find the same three numbers again. That repetition is the scale showing itself, and it is the quickest check that your base unit is right. If the numbers do not repeat, or they divide into awkward fractions, go back to the theme step and look for an overridden --spacing or an unusual root font size.
Handling off-scale values
Not every number will land on a step. Utility classes allow arbitrary values such as p-[13px], and components sometimes carry fixed sizes that never touched the scale. Treat them as findings, not errors.
Don't snap them silently. A 13px padding rounded to 12px changes the layout by one pixel and hides the fact that the original author broke the system. Keep the original value, mark the frame, and decide later whether the design should adopt a step or keep the exception.
Also check the import report for anything that fell back, such as an absolute position where you expected auto layout. An import is faithful and editable, not a pixel-exact clone, so a few values will need a manual look. Fix those in the file rather than assuming the scale applies everywhere.
Conclusion
Keeping a Tailwind spacing scale in Figma comes down to three moves. Read the base unit and the root font size from the real CSS. Convert rem to px once, using a table you trust. Then rebuild the steps as a number variable collection and apply it to padding and gap. The import supplies the numbers; the variables supply the names. When you are ready to go further, building a design system from an imported site covers the next layer: styles, components and handoff.
Questions
- What is the default Tailwind spacing scale?
- In Tailwind v4 the base spacing variable is 0.25rem, and each utility multiplies it, so p-4 is 1rem, or 16px at a 16px root font size.
- Why do my imported paddings not match the Tailwind numbers?
- Usually the site overrides the base spacing variable, or its root font size is not 16px. Read the theme block and the root font-size first, then divide each imported px value by the base unit.
- Does Figma import Tailwind classes?
- No. Figma layers carry numeric values, not class names. You rebuild the scale as number variables and map the imported values to those steps.