---
title: "background(_:alignment:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/view/background(_:alignment:)"
---

# background(_:alignment:)

Layers the given view behind this view.

## Declaration

```swift
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 doc://com.apple.SwiftUI/documentation/SwiftUI/Alignment/center that you use to position the background view.

## Mentioned in

Building layouts with stack views

## Discussion

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. 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())         }     } }

## See Also

### Appearance modifiers

- [colorScheme(_:)](swiftui/view/colorscheme(_:).md)
- [listRowPlatterColor(_:)](swiftui/view/listrowplattercolor(_:).md)
- [overlay(_:alignment:)](swiftui/view/overlay(_:alignment:).md)
- [foregroundColor(_:)](swiftui/view/foregroundcolor(_:).md)
- [complicationForeground()](swiftui/view/complicationforeground().md)
