---
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 the default background style.

## Declaration

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

```

## Parameters

- `shape`: An instance of a type that conforms to doc://com.apple.SwiftUI/documentation/SwiftUI/InsettableShape that SwiftUI draws behind the view using the doc://com.apple.SwiftUI/documentation/SwiftUI/ShapeStyle/background shape style.
- `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 This modifier behaves like background(_:in:fillStyle:), except that it always uses the background shape style to fill the specified insettable shape. For example, you can use a RoundedRectangle as a background on a Label: ZStack {     Color.teal     Label("Flag", systemImage: "flag.fill")         .padding()         .background(in: RoundedRectangle(cornerRadius: 8)) } Without the background modifier, the fill color shows through the label. With the modifier, the label’s text and icon appear backed by a shape filled with a color that’s appropriate for light or dark appearance:

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)
