<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/background(in:fillStyle:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE10background2in9fillStyleQrqd___AA04FillG0VtAA15InsettableShapeRd__lF::OverloadGroup"
  },
  "title" : "background(in:fillStyle:)"
}
-->

# background(in:fillStyle:)

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

```
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 [`InsettableShape`](/documentation/SwiftUI/InsettableShape)
that SwiftUI draws behind the view using the
[`background`](/documentation/SwiftUI/ShapeStyle/background) shape style.

`fillStyle`

The [`FillStyle`](/documentation/SwiftUI/FillStyle) to use when drawing the shape.
The default style uses the nonzero winding number rule and
antialiasing.

## Return Value

A view with the specified insettable shape drawn behind it.

## Discussion

This modifier behaves like [`background(_:in:fillStyle:)`](/documentation/SwiftUI/View/background(_:in:fillStyle:)),
except that it always uses the [`background`](/documentation/SwiftUI/ShapeStyle/background) shape style
to fill the specified insettable shape. For example, you can use
a [`RoundedRectangle`](/documentation/SwiftUI/RoundedRectangle) as a background on a [`Label`](/documentation/SwiftUI/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:

![A screenshot of a flag icon and the word flag inside a rectangle with](images/com.apple.SwiftUI/View-background-9@2x.png)

To create a background with other [`View`](/documentation/SwiftUI/View) types — or with a stack
of views — use [`background(alignment:content:)`](/documentation/SwiftUI/View/background(alignment:content:)) instead.
To add a [`ShapeStyle`](/documentation/SwiftUI/ShapeStyle) as a background, use
[`background(_:ignoresSafeAreaEdges:)`](/documentation/SwiftUI/View/background(_:ignoresSafeAreaEdges:)).

---

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)