<!--
{
  "availability" : [
    "iOS: 13.0.0 - 27.0.0",
    "iPadOS: 13.0.0 - 27.0.0",
    "macCatalyst: 13.0.0 - 27.0.0",
    "macOS: 10.15.0 - 27.0.0",
    "tvOS: 13.0.0 - 27.0.0",
    "visionOS: 1.0.0 - 27.0.0",
    "watchOS: 6.0.0 - 27.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/background(_:alignment:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE10background_9alignmentQrqd___AA9AlignmentVtAaBRd__lF"
  },
  "title" : "background(_:alignment:)"
}
-->

# background(_:alignment:)

Layers the given view behind this view.

```
nonisolated func background<Background>(_ background: Background, alignment: Alignment = .center) -> some View where Background : View
```

## Parameters

`background`

The view to draw behind this view.

`alignment`

The alignment with a default value of
[`center`](/documentation/SwiftUI/Alignment/center) that you use to position the background view.

## Discussion

Use `background(_:alignment:)` when you need to place one view behind
another, with the background view optionally aligned with a specified
edge of the frontmost view.

The example below creates two views: the `Frontmost` view, and the
`DiamondBackground` view. The `Frontmost` view uses the
`DiamondBackground` view for the background of the image element inside
the `Frontmost` view’s [`VStack`](/documentation/SwiftUI/VStack).

```
struct DiamondBackground: View {
    var body: some View {
        VStack {
            Rectangle()
                .fill(Color.gray)
                .frame(width: 250, height: 250, alignment: .center)
                .rotationEffect(.degrees(45.0))
        }
    }
}

struct Frontmost: View {
    var body: some View {
        VStack {
            Image(systemName: "folder")
                .font(.system(size: 128, weight: .ultraLight))
                .background(DiamondBackground())
        }
    }
}
```

![A view showing a large folder image with a gray diamond placed behind it as its background view.](images/com.apple.SwiftUI/View-background-1@2x.png)

---

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)