On this page
- Find the source of spacing disagreements
- Separate numerical values from layout roles
- Specify unit conversion and ownership rules
- Compare representative compositions
- Handle exceptions without expanding the scale endlessly
- Diagnose a doubled field gap
- Make handoff records useful during maintenance
- Key takeaways
How to Keep Design System Spacing Consistent Between Figma and Code is most useful when it becomes a repeatable operating practice rather than an isolated cleanup. Consider a designer and developer resolving repeated spacing mismatches during review. The team needs a clear contract, an owner, and evidence that the result works for consumers. This guide turns spacing parity into a bounded workflow with decisions you can record and revisit.
Find the source of spacing disagreements
Collect a small sample of mismatches and classify them before changing the scale. Common causes include duplicated margins, different root-size assumptions, line boxes mistaken for visible glyph bounds, and nested components each adding their own gap. A pixel difference is an observation, not a diagnosis. Inspect computed styles and layout boundaries alongside design measurements to identify which layer is responsible.
Use the PX to REM Converter to check representative design measurements against the agreed root-size assumption. Record that assumption explicitly rather than treating the tool default as a universal browser setting. Converted values still need review with real content and user text settings.
Set a bounded pilot before changing the whole library. Choose one supported consumer, name the reviewer, and write the acceptance condition in observable terms. Keep the initial scope small enough that the same people can review both the proposal and the resulting implementation.
Separate numerical values from layout roles
Contract review. Keep a modest numerical foundation and define semantic layout roles only where they help consumers choose. A section gap and a control inset can share a value without having the same purpose. Avoid giving every unique screenshot measurement a permanent name. Document how the scale supports component internals, relationships between siblings, and page-level composition so consumers know where to look for the appropriate decision.
For a portable review record, start with explicit fields rather than a paragraph hidden in chat:
{
"role": "field-stack-gap",
"designPx": 12,
"rootPxAssumption": 16,
"implementationRem": 0.75,
"owner": "parent-layout"
}This is an illustrative project record, not an industry interchange format. Add stable identifiers and private source references in your own tracker when they help maintainers verify the evidence.
Specify unit conversion and ownership rules
Implementation evidence. State the assumed root font size for examples and explain that rem values resolve against the actual runtime root size. Do not freeze the root size merely to make screenshots match. Assign external spacing to the parent layout where practical and internal padding to the component. This prevents a reusable component from bringing hidden margins into every context and makes composed layouts easier to reason about.
Consult MDN custom properties guide for the underlying platform or workflow details. Verify the version and capabilities your team actually uses. External guidance establishes technical behavior; your own documentation must still explain which subset the shared system supports and who approves changes to it.
Compare representative compositions
Consumer validation. Build comparison fixtures containing headings, inputs, repeated rows, and nested panels. Use realistic text and the same container dimensions on both sides. Check whether apparent differences come from font metrics or baseline alignment before adjusting space. Review at increased text size and with translated strings. A spacing contract should preserve useful relationships when content changes, not just align the original sample at a single viewport.
Use WCAG 2.2 as a reference for the relevant standards or tooling, not as a substitute for checking your implementation. Record at least one ordinary case and one boundary case. When a result differs from the contract, identify whether the specification, example, or implementation should change before approving the work.
Handle exceptions without expanding the scale endlessly
Maintenance ownership. Record exceptions with their context, owner, and reason. Some optical adjustments are legitimate, but they should not silently redefine the numerical scale. When the same exception appears in several components, investigate whether the role or ownership model is missing. Retire unused values during planned maintenance and provide replacements. A small coherent scale with explicit escape hatches is more useful than a vast catalog nobody can apply consistently.
Keep the review artifact beside the work it governs. Storybook documentation can support the documentation or implementation process, while Design Systems guides provide broader operating context. Use the development directory for adjacent implementation resources. Revisit the decision when a supported consumer exposes a concrete limitation, not merely because a new naming preference appears.
Diagnose a doubled field gap
Suppose a Figma form uses 12 pixels between field groups, but the implementation shows 24 pixels. Inspect the parent layout first. If it supplies a 12-pixel gap and each field also supplies a 12-pixel bottom margin, the discrepancy is an ownership error, not a missing spacing token. Remove external spacing from the field primitive and let the parent stack define the relationship. Check the last field too, since leftover margins can create an unexplained gap before the submit button.
Next compare the label-to-control distance. A design measurement taken from visible letter shapes differs from a browser measurement between line boxes. With a 20-pixel line height, the glyphs do not necessarily fill that entire box. Inspect font family, weight, and line height before changing padding. Otherwise a spacing adjustment made to compensate for the wrong font will become incorrect when the intended font loads.
Finally, repeat the comparison at the documented root assumption. Twelve pixels converts to 0.75rem at a 16-pixel root, but the same rem value resolves to 15 pixels at a 20-pixel root. That larger space may be correct because the user's text setting also changed. Design-code parity means preserving the agreed relationship, not forcing every environment back to a screenshot's absolute coordinates.
Make handoff records useful during maintenance
For each recurring layout role, record its token name, design variable, implementation value, owning layer, and one example composition. A reviewer should be able to trace the field-stack gap from design selection to computed style without consulting a private chat. Keep generated token output separate from the editable source so emergency fixes do not disappear during the next generation run.
When proposing a scale change, list affected roles rather than only the old and new numbers. A foundation value may influence card padding, form gaps, and navigation spacing simultaneously. Review those compositions before approval, and avoid changing unrelated roles merely because they currently share a number. Shared numeric values do not imply identical future requirements.
Key takeaways
- Define the scope and owner of spacing parity before implementation.
- Start with a representative consumer and explicit acceptance evidence.
- Separate policy decisions from what a formatter, generator, or test can prove.
- Review boundary cases and document intentional exceptions.
- Keep the supported contract, examples, and release guidance aligned.
Reach designers & developers at work
Put your product next to the tools people use every day. One sponsor per placement, no tracking pixels.
Become a sponsor