I believe the API for this is contentMargins(for: .container), which is available in the Xcode 27.1 beta, but is not available in the Xcode 27.2 beta or in documentation.
public func contentMargins(for guide: ContentMarginGuide, edges: Edge.Set = .all, alignment: Alignment? = nil) -> some View
The documentation on .container:
The margins of the container the view is in.
These margins are the default spacing to use when laying out
content in a view. The value depends on the platform, the size of
the container, and the position of the view within it.
This guide vends the system layout margins, which range from 16 to 20
points on iPhone and are larger on platforms like tvOS. On iPhone Duo,
the margin can also be asymmetric, applying different values on each
side of the device when next to a vertical bar. Apply or read the guide
instead of writing these values into your layout.
This is an API I've wanted for many years in SwiftUI. It seems awkwardly named (as it conflicts with the concept of contentMargins APIs on scroll views) but glad it's been added.
Hoping they resolve the availability issue for Xcode 27.2 and that its just an issue as they're merging the duo. Currently using this API causes a crash on the Xcode 27.2 beta 2 simulator.
Topic:
SwiftUI
SubTopic:
iPhone Duo SwiftUI Q&A