Compose Unstyled 2.0 is out! Check the official announcement blog ->

A modal scrim that follows the modal transition state.

Installation

implementation("com.composables:composeunstyled-scrim")

Anatomy

Modal(state = state) {
  Scrim()
}

Concepts

  • Scrim renders a modal overlay inside Modal.
  • Scrim follows the modal transition state.

Code Examples

Adding a scrim to a modal

Use the Scrim component inside Modal content:

Modal(state = state) {
  Scrim()
}

Changing scrim color

Use the scrimColor parameter to change the overlay color:

Modal(state = state) {
  Scrim(scrimColor = Color.Black.copy(alpha = 0.4f))
}

Animating a scrim

Use the enter and exit parameters to animate the scrim with the modal state:

Modal(state = state) {
  Scrim(
    enter = fadeIn(),
    exit = fadeOut(),
  )
}

API Reference

ModalScope.Scrim

Parameter Type Description
modifier Modifier
scrimColor Color
enter EnterTransition
exit ExitTransition