<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/UIHostingConfiguration/background(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI22UIHostingConfigurationV10backgroundyACyxAA01_cD14BackgroundViewVyqd__GGqd__AA10ShapeStyleRd__lF"
  },
  "title" : "background(_:)"
}
-->

# background(_:)

Sets the background contents for the hosting configuration’s enclosing
cell.

```
func background<S>(_ style: S) -> UIHostingConfiguration<Content, _UIHostingConfigurationBackgroundView<S>> where S : ShapeStyle
```

## Parameters

`style`

The shape style to be used as the background of the
cell.

## Discussion

The following example sets a custom view to the background of the cell:

```
UIHostingConfiguration {
    Text("My Contents")
}
.background(Color.blue)
```

---

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)