--- id: slds.guidance.utilities.margin title: Margin Utilities description: SLDS margin utility classes for external spacing summary: "Utilities for external spacing. Includes directional (top/right/bottom/left), aggregate (horizontal/vertical/around), and variable density classes. Base unit 4px with sizes from xxx-small (2px) to xx-large (48px)." artifact_type: reference domain: utilities topic: margin content_format: structured complexity: intermediate audience: [implementer] tasks: [implement] refs: - slds.guidance.utilities - slds.guidance.overview.utilities - slds.guidance.utilities.padding - slds.guidance.hooks.spacing tags: [utilities, margin, spacing, external-spacing] keywords: [slds-m, margin, external spacing, whitespace] --- # Margin - External Spacing External spacing between elements. Base unit: **4px**. ## Size Scale | Size | Class Suffix | Value | Pixels | |------|-------------|-------|--------| | None | `none` | 0 | 0px | | XXX Small | `xxx-small` | 0.125rem | 2px | | XX Small | `xx-small` | 0.25rem | 4px | | X Small | `x-small` | 0.5rem | 8px | | Small | `small` | 0.75rem | 12px | | Medium | `medium` | 1rem | 16px | | Large | `large` | 1.5rem | 24px | | X Large | `x-large` | 2rem | 32px | | XX Large | `xx-large` | 3rem | 48px | ## Core Classes ### Directional Margins | Class | Purpose | |-------|---------| | `slds-m-top_*` | Applies margin to the top edge | | `slds-m-right_*` | Applies margin to the right edge | | `slds-m-bottom_*` | Applies margin to the bottom edge | | `slds-m-left_*` | Applies margin to the left edge | ### Aggregate Margins | Class | Purpose | |-------|---------| | `slds-m-horizontal_*` | Applies margin to left and right edges | | `slds-m-vertical_*` | Applies margin to top and bottom edges | | `slds-m-around_*` | Applies margin to all four edges | ### Variable Density Classes | Class | Purpose | Comfy | Compact | |-------|---------|-------|---------| | `slds-var-m-top_*` | Variable density top margin | Full size | 50% size | | `slds-var-m-right_*` | Variable density right margin | Full size | 50% size | | `slds-var-m-bottom_*` | Variable density bottom margin | Full size | 50% size | | `slds-var-m-left_*` | Variable density left margin | Full size | 50% size | | `slds-var-m-horizontal_*` | Variable density horizontal margins | Full size | 50% size | | `slds-var-m-vertical_*` | Variable density vertical margins | Full size | 50% size | | `slds-var-m-around_*` | Variable density all sides | Full size | 50% size | ## Common Patterns ```html