Agentic Design System
v3.5.0

Foundations · Spacing

Spacing

The spacing scale and rhythm every layout, component and page in this system is built from.

What are you building?

Pick the product type closest to yours and the recommended spacing system below updates to match - you can still choose a different one manually afterward.

Spacing system

The base unit every spacing token in this system derives from. 4px Balanced is the global default unless your product type above recommends otherwise.

Recommended global model

The strongest systems don't force a single unit - they combine three, each doing a different job.

Precision

2px

Base / Standard

4px

Structural

8px

Micro spacing Icon-to-text, badge internals, compact controls, fine alignment 2, 4, 6, 8px
Component spacing Button/input padding, card content, form fields, label-to-input 8, 12, 16, 20, 24, 32px
Layout spacing Sections, containers, page-level spacing, major content blocks 24, 32, 40, 48, 64, 80, 96, 128px

AI Rule

Generated interfaces must use a value from this page's Micro / Component / Layout scale for every margin, padding and gap - never an arbitrary pixel value, and never a value interpolated between two scale steps to arrive at a novel spacing. One documented exception: a container's own outer padding (a page shell, a setup panel - not a component's internal spacing) may use clamp(a, Nvw, b) where both a and b are themselves real scale steps, letting that one padding breathe between two approved values across viewport widths instead of jumping between them at a breakpoint - this system's own Project setup panel does exactly this (clamp(20px, 3vw, 32px), both ends on the Balanced scale). Logical properties (margin-inline-end, not margin-right) are required wherever spacing differs by writing direction, so RTL doesn't need a separate rule restated per component.

Component defaults

Values already in real, shipped use, not aspirational ones - each references one of this page's own tokens.

Button Icon-to-label gap; horizontal padding scales with height (12/16/20/24px across the five larger sizes) 8px gap
Table Cell vertical padding (Large); Middle/Small densities step down to 6px and 4px nominal (--space-6 resolves to the active system: 8px at 4px, 6px at 2px) 8px
Modal Two different paddings, not one: the scrim's own padding keeps the dialog off the viewport edge; the dialog's internal content padding is separate and smaller 24px scrim · 16px/20px content
Drawer Same scrim-vs-content split as Modal: scrim padding keeps the panel off the viewport edge; the panel's own content padding is the same value Modal's dialog content uses 16px scrim · 16px/20px content
Panel / Card container Internal padding; Compact density (Settings → Density) steps down to 16px 24px
Form field Vertical gap between label, control and helper/error text - all three in one column, one consistent gap, not a different value per pair 6px nominal gap (8px on the default 4px system)
List Row padding and icon/text gap (Middle density); Small steps down to 6px/8px, Large up to 14px/12px (nominal values: each --space-N snaps to the active spacing system) 10px nominal padding · 10px nominal gap (12px on the default 4px system)
Empty state Panel padding and the gap between icon, heading and body text 24px padding · 10px nominal gap (12px on the default 4px system)

Said plainly, not invented to fill a row: a checkbox/radio group and a toolbar don't have their own formalized spacing value yet - the closest real analog today is Form field's 6px for a checkbox/radio group, and a toolbar isn't a distinct component in this library at all (compose it from Button + the Layout spacing scale above). Wrapped/long content in any of these follows the component's own reflow behavior, not a separate spacing rule.

For developers and AI agents: Markdown export and implementation contract

Spacing tokens - Markdown export

A Markdown snapshot of your current product type and spacing system choices above - regenerates live as you pick, so it's always in sync. Copy it straight into your design system docs or hand it to an AI/agent workflow.

Implementation contract

Saved validated choices override project recommendations, which override system defaults. This implementation contract governs static specimens. Resolved tokens in the current export are authoritative values. Component exceptions must name the affected role and reason.

Scale algorithm

2px, 4px and 8px systems round requested steps to their selected quantum, so a token name such as --space-6 or --space-10 is a nominal request, not a promise of that pixel value (on the default 4px system --space-6 is 8px and --space-10 is 12px). Adaptive uses 2px at requested steps up to 6px, 4px above 6px and below 32px, and 8px from 32px. Positive steps smaller than their quantum keep their original value. --space-n is a compatibility request slot; its resolved value is authoritative. This differs from immutable numeric radius primitives.

Allowed values

Use resolved space tokens for component gaps and padding. Zero is permitted for attached surfaces. auto is permitted for centering/available-space distribution. Percent/viewport units belong to explicitly documented container sizing. Negative margins require a named overlap exception and must not clip focus or targets.

Composition examples

Use 8px label-to-field, 4px field-to-error, 16px field-to-field, 8px checkbox/radio glyph-to-label, 8px related toolbar actions, 24px panel content and 32px between major groups as semantic requests resolved by the active scale. Wrapped labels align with the first line; error text occupies its own row without moving unrelated controls.

Density and targets

Comfortable/compact density affects visual spacing, never the minimum 44px product target. Glyph size, field height and hit area are separate. Reserve room for multilingual labels and validation. A 24px icon is not a 24px touch target.

Context and responsive rules

Single-platform context wins for unsaved recommendations; explicit selection wins thereafter. Cross-Platform is one active scale with documented density/layout variants, not simultaneous conflicting global bases. Logical gutters are equal. Fluid outer padding may interpolate between approved endpoint tokens; internal spacing remains token-based.

Export

Export algorithm, resolved scale, relationship roles, density/target rules, direction and exceptions. Show px/rem equivalents and explain native dp/sp adaptation rather than claiming native CSS support.

Save and edit

Selections preview immediately. Save foundation commits valid settings in this browser and locks the editor. Select Edit foundation to revise saved settings; Cancel retains the saved settings. Storage failure keeps the draft editable.

Machine contract: section rules, storage, units and acceptance
{
  "schemaVersion": 1,
  "authority": "Saved validated choices override project recommendations, which override system defaults. This implementation contract governs static specimens. Resolved tokens in the current export are authoritative values. Component exceptions must name the affected role and reason.",
  "governance": {
    "owners": "Design System Lead owns token and compatibility policy. Designers own specimens and interaction contracts. Developers own resolver/export/import parity. QA and Accessibility own release evidence. Product teams own domain-specific confidence, privacy and retention policies.",
    "changes": "Change the JSON contract first, regenerate documentation/defaults/catalog/tokens, then run model, DOM and recipient checks. Link the changed finding IDs and evidence in the release review.",
    "compatibility": "Keep hue-named CSS tokens as compatibility aliases while semantic consumers migrate. Additive tokens retain schemaVersion 1. A removed/renamed key or changed stored meaning requires a schema migration, a version bump and a documented replacement before release. Keep the prior reader fixture until the migration is verified.",
    "deprecation": "Record old key, replacement, reason, introduced version, planned removal version and affected consumers. Do not remove a token while an active consumer still uses it. Future records are preserved rather than coerced.",
    "scope": "This is a web design system with one shared workspace profile. Native dp/sp adaptation and real agent execution require separate adapters and acceptance. User-defined colors and responsive exceptions require product-specific rendered verification."
  },
  "storage": {
    "version": 1,
    "legacy": "Unversioned valid records migrate in memory. Typography headingScaleVersion 2 applies the smaller six-heading scale once to older records, retaining other roles and existing font/color/style metrics. Later custom size edits are retained. Unsupported future records are preserved. The next successful write stamps the migrated version.",
    "future": "Reject unsupported future versions. Preserve raw data. Offer backup and explicit reset.",
    "invalid": "Foundation selections preview locally until Save foundation succeeds. Saved Foundation editors require Edit foundation before changes. Cancel discards the preview. Invalid drafts never replace saved records; storage failures retain the editable preview and the last durable record.",
    "concurrency": "A storage event refreshes applied tokens and disables stale editor controls until reload. Never merge simultaneous edits silently."
  },
  "units": {
    "base": "1rem = 16px at default browser settings. Do not fix the root font size.",
    "use": "Prefer rem for typography, spacing and control dimensions. Hairline borders and viewport thresholds may use px. Both equivalents appear in Markdown. SVG strokes use viewBox units. Ratios, percentages, columns, timing and weights are unitless or retain their own units.",
    "native": "Web CSS px/rem are not native dp/sp. A native adapter must map semantic roles, support text scaling and test device density. Native rendering is not shipped by this web library."
  },
  "acceptance": [
    "Compare page, applied tokens, durable record, Machine View and exported instructions.",
    "Test valid, unfinished, invalid, missing, malformed, legacy and future records. Exercise storage failure, reset, reload and another tab.",
    "Test 320, 375, 768, 1024 and 1440px widths, 200% zoom, text-spacing overrides, RTL and long/localized labels.",
    "Use keyboard and screen reader. Confirm focus return, names, values, error associations and status announcements.",
    "Verify actual rendered text/surface pairs, forced colors, reduced motion, print and exported recipes in a recipient fixture. Source or DOM checks alone are not rendered acceptance."
  ],
  "layers": {
    "content": 0,
    "sticky": 20,
    "popover": 40,
    "scrim": 60,
    "dialog": 70,
    "toast": 80,
    "tooltip": 90,
    "rules": "Each overlay gets an explicit owner and close/focus-return path. Portal menus out of clipped scroll containers. Nested dialogs stack one scrim per modal owner. Escape closes the top dismissible layer. Tooltips never block actions. Test collision and zoom; do not infer stacking order from shadow size."
  },
  "section": {
    "title": "Spacing",
    "rules": {
      "Scale algorithm": "2px, 4px and 8px systems round requested steps to their selected quantum, so a token name such as --space-6 or --space-10 is a nominal request, not a promise of that pixel value (on the default 4px system --space-6 is 8px and --space-10 is 12px). Adaptive uses 2px at requested steps up to 6px, 4px above 6px and below 32px, and 8px from 32px. Positive steps smaller than their quantum keep their original value. --space-n is a compatibility request slot; its resolved value is authoritative. This differs from immutable numeric radius primitives.",
      "Allowed values": "Use resolved space tokens for component gaps and padding. Zero is permitted for attached surfaces. auto is permitted for centering/available-space distribution. Percent/viewport units belong to explicitly documented container sizing. Negative margins require a named overlap exception and must not clip focus or targets.",
      "Composition examples": "Use 8px label-to-field, 4px field-to-error, 16px field-to-field, 8px checkbox/radio glyph-to-label, 8px related toolbar actions, 24px panel content and 32px between major groups as semantic requests resolved by the active scale. Wrapped labels align with the first line; error text occupies its own row without moving unrelated controls.",
      "Density and targets": "Comfortable/compact density affects visual spacing, never the minimum 44px product target. Glyph size, field height and hit area are separate. Reserve room for multilingual labels and validation. A 24px icon is not a 24px touch target.",
      "Context and responsive rules": "Single-platform context wins for unsaved recommendations; explicit selection wins thereafter. Cross-Platform is one active scale with documented density/layout variants, not simultaneous conflicting global bases. Logical gutters are equal. Fluid outer padding may interpolate between approved endpoint tokens; internal spacing remains token-based.",
      "Export": "Export algorithm, resolved scale, relationship roles, density/target rules, direction and exceptions. Show px/rem equivalents and explain native dp/sp adaptation rather than claiming native CSS support.",
      "Save and edit": "Selections preview immediately. Save foundation commits valid settings in this browser and locks the editor. Select Edit foundation to revise saved settings; Cancel retains the saved settings. Storage failure keeps the draft editable."
    }
  }
}