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

# background(_:ignoresSafeAreaEdges:)

Sets the view’s background to a style.

## Declaration

```swift
nonisolated func background<S>(_ style: S, ignoresSafeAreaEdges edges: Edge.Set = .all) -> some View where S : ShapeStyle

```

## Parameters

- `style`: An instance of a type that conforms to doc://com.apple.SwiftUI/documentation/SwiftUI/ShapeStyle that SwiftUI draws behind the modified view.
- `edges`: The set of edges for which to ignore safe area insets when adding the background. The default value is doc://com.apple.SwiftUI/documentation/SwiftUI/Edge/Set/all. Specify an empty set to respect safe area insets on all edges.

## Return Value

Return Value A view with the specified style drawn behind it.

## Discussion

Discussion Use this modifier to place a type that conforms to the ShapeStyle protocol — like a Color, Material, or HierarchicalShapeStyle — behind a view. For example, you can add the regularMaterial behind a Label: struct FlagLabel: View {     var body: some View {         Label("Flag", systemImage: "flag.fill")             .padding()             .background(.regularMaterial)     } } SwiftUI anchors the style to the view’s bounds. For the example above, the background fills the entirety of the label’s frame, which includes the padding:

SwiftUI limits the background style’s extent to the modified view’s container-relative shape. You can see this effect if you constrain the FlagLabel view with a containerShape(_:) modifier: FlagLabel()     .containerShape(RoundedRectangle(cornerRadius: 16)) The background takes on the specified container shape:

By default, the background ignores safe area insets on all edges, but you can provide a specific set of edges to ignore, or an empty set to respect safe area insets on all edges: Rectangle()     .background(         .regularMaterial,         ignoresSafeAreaEdges: []) // Ignore no safe area insets. If you want to specify a View or a stack of views as the background, use background(alignment:content:) instead. To specify a Shape or InsettableShape, use background(_:in:fillStyle:) . To configure the background of a presentation, like a sheet, use presentationBackground(_:).

## See Also

### Layering views

- [Adding a background to your view](swiftui/adding-a-background-to-your-view.md)
- [ZStack](swiftui/zstack.md)
- [zIndex(_:)](swiftui/view/zindex(_:).md)
- [background(alignment:content:)](swiftui/view/background(alignment:content:).md)
- [background(ignoresSafeAreaEdges:)](swiftui/view/background(ignoressafeareaedges:).md)
- [background(_:in:fillStyle:)](swiftui/view/background(_:in:fillstyle:).md)
- [background(in:fillStyle:)](swiftui/view/background(in:fillstyle:).md)
- [overlay(alignment:content:)](swiftui/view/overlay(alignment:content:).md)
- [overlay(_:ignoresSafeAreaEdges:)](swiftui/view/overlay(_:ignoressafeareaedges:).md)
- [overlay(_:in:fillStyle:)](swiftui/view/overlay(_:in:fillstyle:).md)
- [backgroundMaterial](swiftui/environmentvalues/backgroundmaterial.md)
- [containerBackground(_:for:)](swiftui/view/containerbackground(_:for:).md)
- [containerBackground(for:alignment:content:)](swiftui/view/containerbackground(for:alignment:content:).md)
- [ContainerBackgroundPlacement](swiftui/containerbackgroundplacement.md)
