Figma Variables from UI Libraries to Speed Up Frontend Development
Developers spend up to 50% of their time decoding design specs in Figma: ambiguous terms like flow, duplicated spacing and color values, and no direct link to the codebase. The solution? Use variables from established UI libraries (Tailwind CSS, Bootstrap, MUI) directly inside Figma. This turns design into a living system—frontend development becomes as simple as applying utility classes.
For example, consider a modal with a title, subtitle, input field, and button. Without variables, the designer sees padding: 32px, background: #F9F9F9; the developer manually copies HEX codes into the code.
<div class="modal-window">
<h1 class="modal-title">Subscribe to not miss what matters!</h1>
<p class="modal-subtitle">Enter your email below and click "Send"</p>
<input type="email" class="modal-input" placeholder="[email protected]" />
<button class="modal-button">Send</button>
</div>
.modal-window {
width: 600px;
padding: 32px;
background: #F9F9F9;
border: 1px solid #F2F2F2;
border-radius: 24px;
display: flex;
flex-direction: column;
gap: 24px;
}
.modal-title {
color: #323232;
font-size: 20px;
font-weight: 500;
}
/* Similar styles for other elements */
Duplicated styles mean manual updates across files when changes occur.
Problems with the Traditional Approach
Frontend developers reinterpret each component’s design from scratch:
- Vague naming:
radiusinstead ofborder-radius,flowinstead offlex-direction. - Ignoring properties:
widthis relevant, butheight/top/leftare ignored. - Redundant values:
border 1px solidrepeated multiple times. - No system integration: design values aren’t tied to the actual library.
With 10 modals, updates require searching, decoding, and copying across all files. This repetitive work slows down delivery and makes scaling difficult.
Rule: Every reusable value should be a variable.
Implementing Tailwind CSS Variables
Choose a library as your source of truth. Tailwind offers utility classes for padding, colors, and corner radius.
Step 1: Gather Variables
Colors:
white-100: #FFFFFFwhite-200: #F2F2F2blue-500: #066BE8
Spacing:
p-3: 12pxp-4: 16pxp-6: 24pxp-8: 32px
Rounded corners:
rounded-lg: 8pxrounded-3xl: 24px
Border: border: 1px
If a value is missing, create it using consistent naming (e.g., p-9: 36px).
Step 2: Import into Figma
Create variable groups. After syncing, Figma displays values directly on components (padding, radius, etc.).
Step 3: Apply to Design
Modal: p-8, bg-white-400, border, rounded-3xl.
Input: bg-white-100, border, rounded-lg, p-4 (16px × 12px).
Button: bg-blue-500, rounded-lg, p-3 (12px × 36px).
The developer sees p-8 bg-white-400 rounded-3xl and writes:
<div class="p-8 bg-white-400 border rounded-3xl flex flex-col gap-6">
No HEX codes. No measurements. Just clean utility classes.
Adapting for Other Libraries
Bootstrap:
p-3, bg-light, border, text-primary.
<div class="p-3 bg-light border border-1 rounded">
<h5 class="text-primary">Title</h5>
<button class="btn btn-primary">Send</button>
</div>
Material UI:
theme.spacing(4), grey.100.
import { Box, Button, TextField } from "@mui/material";
export default function Modal() {
return (
<Box sx={{ p: 4, backgroundColor: "grey.100", border: "1px solid", borderColor: "grey.200", borderRadius: 3, display: "flex", flexDirection: "column", gap: 3 }}>
<TextField placeholder="Email" />
<Button variant="contained" color="primary">Send</Button>
</Box>
);
}
Chakra UI:
p="8", bg="gray.100".
import { Box, Button, Input } from "@chakra-ui/react";
export default function Modal() {
return (
<Box p="8" bg="gray.100" border="1px" borderColor="gray.200" borderRadius="3xl" display="flex" flexDirection="column" gap="6">
<Input placeholder="Email" />
<Button colorScheme="blue">Send</Button>
</Box>
);
}
Custom Variables with SASS/SCSS
For projects without frameworks, use preprocessors:
$white-100: #FFFFFF;
$p-8: 32px;
$rounded-3xl: 24px;
@mixin modal-base {
padding: $p-8;
background: $white-400;
border: 1px solid $white-200;
border-radius: $rounded-3xl;
}
.modal {
@include modal-base;
display: flex;
flex-direction: column;
gap: $gap-6;
}
Mixins standardize components; variables centralize values.
Key Takeaways
- Library-based variables eliminate duplication and interpretation—development speed increases by up to 50%.
- Figma + Tailwind/MUI: designers apply classes, developers copy them.
- Scalability: change one variable, update the entire project.
- For mid/senior devs: focus on systems, not busywork.
- Bonus: Figma shows numeric values of variables in real time.
— Editorial Team
No comments yet.