---
title: "sizeThatFits(in:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/uihostingcontroller/sizethatfits(in:)"
---

# sizeThatFits(in:)

Calculates and returns the most appropriate size for the current view.

## Declaration

```swift
@MainActor @preconcurrency func sizeThatFits(in size: CGSize) -> CGSize
```

## Parameters

- `size`: The proposed new size for the view.

## Return Value

Return Value The size that offers the best fit for the root view and its contents.

## See Also

### Managing the size

- [sizingOptions](swiftui/uihostingcontroller/sizingoptions.md)
- [preferredContentSizeDidChange(forChildContentContainer:)](swiftui/uihostingcontroller/preferredcontentsizedidchange(forchildcontentcontainer:).md)
- [safeAreaRegions](swiftui/uihostingcontroller/safearearegions.md)
