---
title: UIHostingConfiguration
framework: swiftui
role: symbol
role_heading: Structure
path: swiftui/uihostingconfiguration
---

# UIHostingConfiguration

A content configuration suitable for hosting a hierarchy of SwiftUI views.

## Declaration

```swift
struct UIHostingConfiguration<Content, Background> where Content : View, Background : View
```

## Overview

Overview Use a value of this type, which conforms to the UIContentConfiguration protocol, with a UICollectionViewCell or UITableViewCell to host a hierarchy of SwiftUI views in a collection or table view, respectively. For example, the following shows a stack with an image and text inside the cell: myCell.contentConfiguration = UIHostingConfiguration {     HStack {         Image(systemName: "star").foregroundStyle(.purple)         Text("Favorites")         Spacer()     } } You can also customize the background of the containing cell. The following example draws a blue background: myCell.contentConfiguration = UIHostingConfiguration {     HStack {         Image(systemName: "star").foregroundStyle(.purple)         Text("Favorites")         Spacer()     } } .background {     Color.blue } When used in a list layout, certain APIs are bridged automatically, like swipe actions and separator alignment. The following example shows a trailing yellow star swipe action: cell.contentConfiguration = UIHostingConfiguration {     HStack {         Image(systemName: "airplane")         Text("Flight 123")         Spacer()     }     .swipeActions {         Button { ... } label: {             Label("Favorite", systemImage: "star")         }         .tint(.yellow)     } }

## Topics

### Creating and updating a configuration

- [init(content:)](swiftui/uihostingconfiguration/init(content:).md)

### Setting the background

- [background(_:)](swiftui/uihostingconfiguration/background(_:).md)
- [background(content:)](swiftui/uihostingconfiguration/background(content:).md)

### Setting margins

- [margins(_:_:)](swiftui/uihostingconfiguration/margins(_:_:).md)

### Setting a size

- [minSize(width:height:)](swiftui/uihostingconfiguration/minsize(width:height:).md)
- [minSize()](swiftui/uihostingconfiguration/minsize().md)

## Relationships

### Conforms To

- [UIContentConfiguration](uikit/uicontentconfiguration-9eib5.md)

## See Also

### Displaying SwiftUI views in UIKit

- [Using SwiftUI with UIKit](uikit/using-swiftui-with-uikit.md)
- [Unifying your app’s animations](swiftui/unifying-your-app-s-animations.md)
- [UIHostingController](swiftui/uihostingcontroller.md)
- [UIHostingControllerSizingOptions](swiftui/uihostingcontrollersizingoptions.md)
- [UIHostingSceneDelegate](swiftui/uihostingscenedelegate.md)
