ui-unit
Interfaces
  • Density
  • FontScaling
Functions
  • Constraints
  • Density
  • DpOffset
  • DpSize
  • IntOffset
  • IntRect
  • IntSize
  • TextUnit
  • Velocity
  • coerceAtLeast
  • coerceAtMost
  • coerceIn
  • constrain
  • constrainHeight
  • constrainWidth
  • isSatisfiedBy
  • lerp
  • max
  • min
  • minus
  • offset
  • plus
  • round
  • roundToIntRect
  • roundToIntSize
  • takeOrElse
  • times
  • toIntRect
  • toIntSize
  • toOffset
  • toRect
  • toSize
Objects
  • ComposeUiUnitFlags
Classes
  • Constraints
  • Dp
  • DpOffset
  • DpRect
  • DpSize
  • ExperimentalUnitApi
  • IntOffset
  • IntRect
  • IntSize
  • LayoutDirection
  • LayoutDirection.Ltr
  • LayoutDirection.Rtl
  • TextUnit
  • TextUnitType
  • Velocity
Properties
  • center
  • dp
  • em
  • height
  • isFinite
  • isSpecified
  • isUnspecified
  • size
  • sp
  • width
Jetpack Compose / Compose UI / ui-unit / Functions / coerceIn
Function

coerceIn

View Markdown Open in ChatGPT Open in Claude

Ensures that this value lies in the specified range minimumValue..maximumValue.

CodeRabbit

CodeRabbit

AI writes the code. CodeRabbit catches the slop.

Ad Try CodeRabbit for Free

coerceIn

Source set: Common
public inline fun Dp.coerceIn(minimumValue: Dp, maximumValue: Dp): Dp

Ensures that this value lies in the specified range minimumValue..maximumValue.

Return

this value if it's in the range, or minimumValue if this value is less than minimumValue, or maximumValue if this value is greater than maximumValue.

Content updated: 2026-10-21

coerceAtMost ← Previous constrain Next →

On this page

  • coerceIn
Reach Android developers Put your product in front of engineers building Android and KMP apps. Sponsor Composables