<!--
{
  "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:)-20tq5",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE10background_2in9fillStyleQrqd___qd_0_AA04FillG0VtAA05ShapeG0Rd__AA010InsettableI0Rd_0_r0_lF"
  },
  "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` that SwiftUI uses to the fill the shape
that you specify.

`shape`

An instance of a type that conforms to `InsettableShape`
that SwiftUI draws behind the view.

`fillStyle`

The `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` 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 `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` types — or with a stack
of views — use `View/background(alignment:content:)` instead.
To add a `ShapeStyle` as a background, use
`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)