---
title: "Container Content Margins | Explore SwiftUI"
description: "Adds the margins of the container the view is in. Learn how to use Container Content Margins in SwiftUI with visual code examples."
canonical_url: "https://exploreswiftui.com/library/view/container-content-margins"
meta:
  author: "Explore SwiftUI"
  "og:description": "Adds the margins of the container the view is in. Learn how to use Container Content Margins in SwiftUI with visual code examples."
  "og:image": "https://exploreswiftui.com/_og/d/c_Component%2Ctitle_Container%2BContent%2BMargins%2Cdescription_Explore%2Bvisually%2Bwith%2Bcode%2Bexamples%2Ccategory_View%2Cprops_eyJwbGF0Zm9ybXMiOlsiaU9TIiwiaVBhZE9TIiwibWFjT1MiLCJ3YXRjaE9TIiwidmlzaW9uT1MiXX0%2Cp_Ii9saWJyYXJ5L3ZpZXcvY29udGFpbmVyLWNvbnRlbnQtbWFyZ2lucyI%2Cs_WEXWucXOn35Q_EQV.png"
  "og:image:height": "630"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "Container Content Margins | Explore SwiftUI"
  "twitter:description": "Adds the margins of the container the view is in. Learn how to use Container Content Margins in SwiftUI with visual code examples."
  "twitter:image": "https://exploreswiftui.com/_og/d/c_Component%2Ctitle_Container%2BContent%2BMargins%2Cdescription_Explore%2Bvisually%2Bwith%2Bcode%2Bexamples%2Ccategory_View%2Cprops_eyJwbGF0Zm9ybXMiOlsiaU9TIiwiaVBhZE9TIiwibWFjT1MiLCJ3YXRjaE9TIiwidmlzaW9uT1MiXX0%2Cp_Ii9saWJyYXJ5L3ZpZXcvY29udGFpbmVyLWNvbnRlbnQtbWFyZ2lucyI%2Cs_WEXWucXOn35Q_EQV.png"
  "twitter:title": "Container Content Margins | Explore SwiftUI"
---

> Index of every page on this site: [llms.txt](https://exploreswiftui.com/llms.txt)

**Interactive previews**[ iPhone Duo](https://exploreswiftui.com/duo?element=257) [ iPhone](https://exploreswiftui.com/iphone?element=257)

# **Container Content Margins**

Adds the margins of the container the view is in.

![Container Content Margins - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/257/variants/1987?v=1792070676534&r=2&w=800&q=80&f=webp)

### **Platform Compatibility**

iOS 27.1+ iPadOS 27.1+ macOS 27.1+ watchOS 27.1+ visionOS 27.1+

### **Tags**

### **SwiftUI Code**

[ Docs](https://developer.apple.com/documentation/swiftui/contentmarginguide/container)

```
VStack(spacing: 0) {
    Color.blue
    Color.indigo
        .contentMargins(
            for: .container,
            edges: .all
        )
    List {
        Text("FooBar")
    }
}
```

### **Found an issue or have a suggestion?**

Created: October 15, 2026Updated: October 15, 2026

![Connect Wizard](https://exploreswiftui.com/_ipx/f_webp&q_80&s_48x48/images/connect-wizard-icon.png)

**Connect Wizard**

**Unlock insights App Store Connect doesn’t show you.**

[** Get Started **](https://apps.apple.com/app/apple-store/id6747314580?pt=121213751&ct=Explore%20SwiftUI%20Banner&mt=8)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://exploreswiftui.com/#website","@type":"WebSite","description":"A visual library for SwiftUI APIs, components, and modifiers","inLanguage":"en-US","name":"Explore SwiftUI","url":"https://exploreswiftui.com/","publisher":{"@id":"https://exploreswiftui.com/#identity"}},{"@id":"https://exploreswiftui.com/library/view/container-content-margins#webpage","@type":"WebPage","dateModified":"2026-10-15T13:24:36.722Z","datePublished":"2026-10-15T13:03:23.605Z","description":"Adds the margins of the container the view is in. Learn how to use Container Content Margins in SwiftUI with visual code examples.","name":"Container Content Margins","url":"https://exploreswiftui.com/library/view/container-content-margins","breadcrumb":{"@id":"https://exploreswiftui.com/library/view/container-content-margins#breadcrumb"},"isPartOf":{"@id":"https://exploreswiftui.com/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://exploreswiftui.com/library/view/container-content-margins"]}],"primaryImageOfPage":{"@id":"https://exploreswiftui.com/#logo"}},{"@id":"https://exploreswiftui.com/#identity","@type":"Organization","description":"A visual library for SwiftUI APIs, components, and modifiers","name":"Explore SwiftUI","url":"https://exploreswiftui.com","logo":{"@id":"https://exploreswiftui.com/#logo"},"sameAs":["https://x.com/Typ0genius","https://mastodon.social/@Typ0genius"]},{"@id":"https://exploreswiftui.com/library/view/container-content-margins#article","dateModified":"2026-10-15T13:24:36.722Z","datePublished":"2026-10-15T13:03:23.605Z","description":"Adds the margins of the container the view is in. Learn how to use Container Content Margins in SwiftUI with visual code examples.","headline":"Container Content Margins","inLanguage":"en-US","name":"Container Content Margins","thumbnailUrl":"https://exploreswiftui.com/api/images/257/variants/1987?v=1792070676534&r=2","url":"https://exploreswiftui.com/library/view/container-content-margins","@type":["Article","TechArticle"],"about":{"@type":"Thing","name":"SwiftUI"},"author":{"@id":"https://exploreswiftui.com/#identity"},"image":{"@id":"https://exploreswiftui.com/#/schema/image/1"},"isPartOf":{"@type":"WebSite","name":"Explore SwiftUI","url":"https://exploreswiftui.com"},"mainEntityOfPage":{"@id":"https://exploreswiftui.com/library/view/container-content-margins#webpage"},"publisher":{"@id":"https://exploreswiftui.com/#identity"}},{"@id":"https://exploreswiftui.com/library/view/container-content-margins#/schema/software-source-code/1","@type":"SoftwareSourceCode","codeRepository":"https://developer.apple.com/documentation/swiftui/contentmarginguide/container","codeSampleType":"full example","description":"Adds the margins of the container the view is in. Learn how to use Container Content Margins in SwiftUI with visual code examples.","name":"Container Content Margins SwiftUI Example","programmingLanguage":"Swift","runtimePlatform":"SwiftUI","text":"VStack(spacing: 0) {\n    Color.blue\n    Color.indigo\n        .contentMargins(\n            for: .container,\n            edges: .all\n        )\n    List {\n        Text(\"FooBar\")\n    }\n}","about":[{"@type":"Thing","name":"SwiftUI"},{"@type":"Thing","name":"View"},{"@type":"Thing","name":"Container Content Margins"}]},{"@id":"https://exploreswiftui.com/library/view/container-content-margins#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Home","item":"https://exploreswiftui.com","position":1},{"@type":"ListItem","name":"View","item":"https://exploreswiftui.com/library/view","position":2},{"@type":"ListItem","name":"Container Content Margins","item":"https://exploreswiftui.com/library/view/container-content-margins","position":3}]},{"@id":"https://exploreswiftui.com/#logo","@type":"ImageObject","caption":"Explore SwiftUI","contentUrl":"https://exploreswiftui.com/apple-touch-icon.png","inLanguage":"en","url":"https://exploreswiftui.com/apple-touch-icon.png"},{"@id":"https://exploreswiftui.com/#/schema/image/1","@type":"ImageObject","contentUrl":"https://exploreswiftui.com/api/images/257/variants/1987?v=1792070676534&r=2","inLanguage":"en","url":"https://exploreswiftui.com/api/images/257/variants/1987?v=1792070676534&r=2"}]}
```