Is there a way to override `DropdownMenuItem`’s cl...
# compose
a
Is there a way to override `DropdownMenuItem`’s click indication color outside of the material theme? I’ve tried this to no success
Copy code
DropdownMenuItem(onClick = { /*TODO*/ }, 
                 modifier = Modifier
                .indication(
                            interactionSource = remember { MutableInteractionSource() } , 
                            rememberRipple(color = Color.Red))) {
   Text("Some Menu Item")
}
v
Try wrapping
DropdownMenuItem
with
Copy code
CompositionLocalProvider(LocalRippleTheme provides object : RippleTheme by LocalRippleTheme.current {
    @Composable
    override fun defaultColor(): Color = Color.Red
}) {
    ...
}
A bit sneaky way but it should work. No direct way now unfortunately
a
@Vsevolod Ganin Fantastic!!!! thank you for the suggestion. I’ll try it out. 🎉
worked like a charm!!! Thank you so much!
👍🏻 1
I spent way too much time trying to figure that out
c
@Louis Pullen-Freilich [G] is this the expected workaround?
l
It depends what exactly you are trying to do, just wanting to change the indication color seems a bit strange - do you want it to be a different color from the text then? If so then this probably is the best workaround, since you are explicitly trying to change the ripple theme that is used inside
Otherwise the ripple will use
LocalContentColor
by default (as will the text), so you can just provide that around the
DropdownMenuItem
👍 2
a
@Louis Pullen-Freilich [G] Thanks for that info. I’ll try that out