Skip to main content

Overview

Control the spacing between children in an auto-layout frame. You can set both the gap between items along the primary axis and the gap between rows/columns when wrapping is enabled.

Parameters

nodeId
string
required
The ID of the frame to modify
itemSpacing
number
Distance between children in pixels along the primary axis (horizontal for HORIZONTAL layouts, vertical for VERTICAL layouts)
This value will be ignored if primaryAxisAlignItems is set to SPACE_BETWEEN.
counterAxisSpacing
number
Distance between wrapped rows or columns in pixels
Only works when layoutWrap is set to WRAP.

Response

Examples

Standard button group spacing

Tight spacing for list items

Card grid with wrapping

Comfortable section spacing

Dense icon row

Spacing Guidelines

Common Spacing Values

  • 4px: Very tight spacing (icons, badges)
  • 8px: Tight spacing (compact lists, form field groups)
  • 12px: Standard spacing (button groups, navigation items)
  • 16px: Comfortable spacing (cards, sections)
  • 24px: Loose spacing (major sections, generous layouts)
  • 32px+: Very loose spacing (hero sections, large containers)

Spacing by Component Type

Understanding Spacing Types

itemSpacing (Primary Axis)

  • For horizontal layouts: Gap between items left-to-right
  • For vertical layouts: Gap between items top-to-bottom
  • Ignored when primaryAxisAlignItems is SPACE_BETWEEN

counterAxisSpacing

  • For horizontal layouts with wrapping: Gap between rows
  • For vertical layouts with wrapping: Gap between columns
  • Only active when layoutWrap is set to WRAP

Use Cases

Button groups: Use 8-12px spacing for related action buttons Navigation menus: Use 12-16px spacing for easy click targets Card grids: Use 16-24px spacing for visual separation Form fields: Use 16-24px spacing to group related inputs Icon toolbars: Use 4-8px spacing for compact tool rows

Complete Example: Responsive Card Grid

Design Tips

  • Use multiples of 4 or 8 for spacing consistency
  • Increase spacing between major sections to establish visual hierarchy
  • Tighter spacing suggests stronger relationships between items
  • Match your spacing scale to your design system (e.g., 4, 8, 12, 16, 24, 32, 48)