Detent object provides methods for creating presentation detent configurations that control how sheets can be sized and positioned on screen. Detents define the snap points where a sheet will rest when presented.
Properties and Methods
Detent.medium
A standard medium-sized detent, typically around half the screen height.
{ detentType: 'medium' }
Detent.large
A large detent that typically fills most or all of the available screen space.
{ detentType: 'large' }
Detent.fraction(value: number)
Creates a custom detent at a fractional position of the screen height.
Parameters:
value- A number between 0 and 1 representing the fraction of screen height (e.g., 0.5 for half screen)
{ detentType: 'fraction', value: number }
Detent.height(value: number)
Creates a custom detent with a fixed height in points.
Parameters:
value- The fixed height in points
{ detentType: 'height', value: number }
Usage
Detents are used with thepresentationDetents modifier to configure sheet presentations:
Single detent
Multiple detents
Custom fractional detent
Fixed height sheet
Combining different detent types
Notes
- Detents define the positions where a sheet will snap when dragged by the user
- Multiple detents allow users to resize the sheet by dragging between defined sizes
- The order of detents in the array doesn’t matter - the sheet will snap to the closest detent
- On platforms that don’t support detents, sheets typically default to full screen
Detent.mediumandDetent.largeare semantic and adapt to platform conventions- Fraction values should be between 0 and 1 (values outside this range may behave unpredictably)
- Height values are in points and should account for safe area insets
- When no detents are specified, sheets typically default to
[Detent.large]
