---
title: CustomPresentationDetent
framework: swiftui
role: symbol
role_heading: Protocol
path: swiftui/custompresentationdetent
---

# CustomPresentationDetent

The definition of a custom detent with a calculated height.

## Declaration

```swift
protocol CustomPresentationDetent
```

## Overview

Overview You can create and use a custom detent with built-in detents. extension PresentationDetent {     static let bar = Self.custom(BarDetent.self)     static let small = Self.height(100)     static let extraLarge = Self.fraction(0.75) }

private struct BarDetent: CustomPresentationDetent {     static func height(in context: Context) -> CGFloat? {         max(44, context.maxDetentValue * 0.1)     } }

struct ContentView: View {     @State private var showSettings = false     @State private var selectedDetent = PresentationDetent.bar

var body: some View {         Button("View Settings") {             showSettings = true         }         .sheet(isPresented: $showSettings) {             SettingsView(selectedDetent: $selectedDetent)                 .presentationDetents(                     [.bar, .small, .medium, .large, .extraLarge],                     selection: $selectedDetent)         }     } }

## Topics

### Getting the height

- [height(in:)](swiftui/custompresentationdetent/height(in:).md)
- [CustomPresentationDetent.Context](swiftui/custompresentationdetent/context.md)

## See Also

### Configuring a sheet’s height

- [presentationDetents(_:)](swiftui/view/presentationdetents(_:).md)
- [presentationDetents(_:selection:)](swiftui/view/presentationdetents(_:selection:).md)
- [presentationContentInteraction(_:)](swiftui/view/presentationcontentinteraction(_:).md)
- [presentationDragIndicator(_:)](swiftui/view/presentationdragindicator(_:).md)
- [PresentationDetent](swiftui/presentationdetent.md)
- [PresentationContentInteraction](swiftui/presentationcontentinteraction.md)
