<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: 26.0.0 -",
    "macOS: 26.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 26.0.0 -",
    "watchOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/containerShape(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE14containerShapeyQrqd__AA018RoundedRectangularE0Rd__lF::OverloadGroup"
  },
  "title" : "containerShape(_:)"
}
-->

# containerShape(_:)

Sets the container shape to use for any container relative shape or
concentric rectangle within this view.

```
nonisolated func containerShape(_ shape: some RoundedRectangularShape) -> some View
```

## Discussion

The example below defines a view that shows its content with a rounded
rectangle background and the same container shape. Any
[`ContainerRelativeShape`](/documentation/SwiftUI/ContainerRelativeShape) within the `content` matches the rounded
rectangle shape from this container inset as appropriate. Any
[`ConcentricRectangle`](/documentation/SwiftUI/ConcentricRectangle) within the `content` will match the corners to
be concentric to the container corners.

```
struct PlatterContainer<Content: View> : View {
    @ContentBuilder var content: Content
    var body: some View {
        content
            .padding()
            .containerShape(shape)
            .background(shape.fill(.background))
    }
    var shape: RoundedRectangle { RoundedRectangle(cornerRadius: 20) }
}
```

> SeeAlso: ``doc://com.apple.SwiftUI/documentation/SwiftUI/View/containerShape(_:)-qn9q``

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)