<!--
{
  "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:7SwiftUI4ViewPAAE10background_2in9fillStyleQrqd___qd_0_AA04FillG0VtAA05ShapeG0Rd__AA010InsettableI0Rd_0_r0_lF::OverloadGroup"
  },
  "title" : "background(_:in:fillStyle:)"
}
-->

# background(_:in:fillStyle:)

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

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

## Parameters

`style`

A [`ShapeStyle`](/documentation/SwiftUI/ShapeStyle) that SwiftUI uses to the fill the shape
that you specify.

`shape`

An instance of a type that conforms to [`InsettableShape`](/documentation/SwiftUI/InsettableShape)
that SwiftUI draws behind the view.

`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

Use this modifier to layer a type that conforms to the
[`InsettableShape`](/documentation/SwiftUI/InsettableShape) protocol — like a [`Rectangle`](/documentation/SwiftUI/Rectangle), [`Circle`](/documentation/SwiftUI/Circle), or
[`Capsule`](/documentation/SwiftUI/Capsule) — behind a view. Specify the [`ShapeStyle`](/documentation/SwiftUI/ShapeStyle) that’s used to
fill the shape. For example, you can place a [`RoundedRectangle`](/documentation/SwiftUI/RoundedRectangle)
behind a [`Label`](/documentation/SwiftUI/Label):

```
Label("Flag", systemImage: "flag.fill")
    .padding()
    .background(.teal, in: RoundedRectangle(cornerRadius: 8))
```

The [`teal`](/documentation/SwiftUI/ShapeStyle/teal) color fills the shape:

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

This modifier is a convenience method for placing a single shape behind a view. 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)