Key takeaways
- Name CSS variables by role.
- Convert Figma opacity to alpha explicitly.
- Keep one source of truth for colors.
Mismatched colors between design and code are a common and avoidable source of rework. A few habits remove most of the risk.
Step 1: Copy the hex from Figma
Select the layer, open the Fill section and copy the hex value. Our Figma plugin shows HEX, RGB and HSL for the selection, and its contrast.
Step 2: Create CSS variables
Name them by role, not by appearance, so they survive a rebrand.
:root {
--color-action: #3b6cff;
--color-surface: #f6f6fa;
}Step 3: Handle opacity
Figma shows opacity separately from the hex. Convert it with the hex with opacity tool to get an 8-digit hex or an rgb value with alpha.
--color-overlay: #0c0c1480; /* or */ --color-overlay: rgb(12 12 20 / 50%);
Step 4: Compare on screen
Check a few colors side by side in the browser and in Figma. Both should use sRGB.
Step 5: Keep one source of truth
Export tokens from the design file or store them in one CSS file. Avoid copying hex codes by hand into many places.
Wrap up
With role-based variables and a single source of truth, design updates become one-line changes.