androidx.compose.material3
ScrimSince 1.11
Composable function
One of the helpers on this page. It works like ProvideTextStyle. Only the parameters that differ are described here.
A dim layer over content. Use it behind your own popup, and close the popup in onClick.

Box(Modifier.size(240.dp, 120.dp)) {
Text("Content under the scrim", Modifier.padding(16.dp))
Scrim(contentDescription = "Close", onClick = { /* close what is on top */ }, alpha = { 0.6f })
}
Parameters
@Composable
fun Scrim(
contentDescription: String?,
modifier: Modifier = Modifier,
onClick: (() -> Unit)? = {},
alpha: () -> Float = { 1f },
color: Color = ScrimDefaults.color,
)
contentDescription: String?Required
contentDescription: String?RequiredWhat the scrim is, for screen readers, like "Close menu". Pass null if it can't be clicked.
modifier: ModifierOptional
modifier: ModifierOptionalDefault: Modifier
Changes size, padding, or position. See the Modifier guide.
onClick: (() -> Unit)?Optional
onClick: (() -> Unit)?OptionalDefault: {}
Called when the scrim is clicked, usually to close what is on top.
alpha: () -> FloatOptional
alpha: () -> FloatOptionalDefault: { 1f }
How strong the scrim is, from 0 (clear) to 1 (full color). A function, so it can animate cheaply.
color: ColorOptional
color: ColorOptionalDefault: ScrimDefaults.color
The scrim color.