Installation
implementation("com.composables:composeunstyled-scrim")
Anatomy
Modal(state = state) {
Scrim()
}
Concepts
Scrimrenders a modal overlay insideModal.Scrimfollows 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 |