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

# background(_:in:fillStyle:)

Sets the view’s background to an insettable shape filled with a style.

## Declaration

```swift
nonisolated func background<S, T>(_ style: S, in shape: T, fillStyle: FillStyle = FillStyle()) -> some View where S : ShapeStyle, T : InsettableShape

```

## Parameters

- `style`: A doc://com.apple.SwiftUI/documentation/SwiftUI/ShapeStyle that SwiftUI uses to the fill the shape that you specify.
- `shape`: An instance of a type that conforms to doc://com.apple.SwiftUI/documentation/SwiftUI/InsettableShape that SwiftUI draws behind the view.
- `fillStyle`: The doc://com.apple.SwiftUI/documentation/SwiftUI/FillStyle to use when drawing the shape. The default style uses the nonzero winding number rule and antialiasing.

## Return Value

Return Value A view with the specified insettable shape drawn behind it.

## Discussion

Discussion Use this modifier to layer a type that conforms to the InsettableShape protocol — like a Rectangle, Circle, or Capsule — behind a view. Specify the ShapeStyle that’s used to fill the shape. For example, you can place a RoundedRectangle behind a Label: Label("Flag", systemImage: "flag.fill")     .padding()     .background(.teal, in: RoundedRectangle(cornerRadius: 8)) The teal color fills the shape:

This modifier is a convenience method for placing a single shape behind a view. To create a background with other View types — or with a stack of views — use background(alignment:content:) instead. To add a ShapeStyle as a background, use background(_:ignoresSafeAreaEdges:).

## 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(ignoresSafeAreaEdges:)](swiftui/view/background(ignoressafeareaedges:).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)
