How can I change the ripple color of an IconButton?
I tried doing it this way, but it doesn't change:
IconButton(
onClick = { onClick() },
modifier = Modifier.clickable(
onClick = { onClick() },
indication = rememberRipple(color = MyCustomTheme.colors.primary),
interactionSource = remember { MutableInteractionSource() },
)
)
I don't know if you found a way to make it work for the whole app but I found a way to do so. So I'm posting this incase someone else has a similar issue.
You can set the custom
RippleTheme
object as described by Gabriele Mariotti's answer then you can pass theCompositionLocalProvider()
as content in MaterialTheme. The content from the app'stheme
can then be set as content forCompositionalLocalProvider()
.Take a look here:
Then for your app theme it should be:
This method should work for the whole app unless you explicitly set another
RippleTheme
directly to Composables below theAppTheme
hierarchy. And it doesn't conflict with other types ofComposableLocalProvider
values you may set directly to your otherComposables
.