In 2022 Apple again introduced new changes in SwiftUI.
Previously, when we showed a sheet we had the option to show it but we couldn’t change its size. This time we can change the height of the sheet.
@State private var isSheetVisible = false
var body: some View {
Button(“Show sheet”) {
isSheetVisible.toggle()
}
.sheet(isPresented: $isSheetVisible) {
Color.blue
}
}
When you take this code and run then you’ll see button with sheet on click:

In iOS 16 / Xcode 14.0 we have a new view modifier called presentationDetents which sets the height of the sheet.
If you need to set some view height percentage then you can put .friction:
.sheet(isPresented: $isSheetVisible) {
Color.blue
.presentationDetents([.fraction(0.4)])
}
}

For example, a sheet will have 40% height.
However, if you need to set specific height then you can put .height:
.sheet(isPresented: $isSheetVisible) {
Color.blue
.presentationDetents([.height(100)])}
}

Sheet will have a height of 100.
There are more options, .medium which is more or less half of the screen, .large which is full screen or .custom where you can create your own modifier.
If you see such error:

Then it means that you have an old version of Xcode, you need to have Xcode 14.0 or newer.