---
title: "margins(_:_:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/uihostingconfiguration/margins(_:_:)"
---

# margins(_:_:)

Sets the margins around the content of the configuration.

## Declaration

```swift
func margins(_ edges: Edge.Set = .all, _ insets: EdgeInsets) -> UIHostingConfiguration<Content, Background>
```

## Parameters

- `edges`: The edges to apply the insets. Any edges not specified will use the system default values. The default value is doc://com.apple.SwiftUI/documentation/SwiftUI/Edge/Set/all.
- `insets`: The insets to apply.

## Discussion

Discussion Use this modifier to replace the default margins applied to the root of the configuration. The following example creates 10 points of space between the content and the background on the leading edge and 20 points of space on the trailing edge: UIHostingConfiguration {     Text("My Contents") } .margins(.horizontal, 20.0)
