Search code examples
androidandroid-jetpack-compose

Unbound Ripple/Indication in Jetpack Compose (equivalent to selectableBackgroundBorderless)


In Jetpack Compose the clickable Modifier will by default use LocalIndication.current and show a ripple that is bound to the border. That looks great almost always, but there are some circumstances where a rounded, unbound ripple looks better. Back in View Android we would've used android:background="?attr/selectableItemBackgroundBorderless to achieve this behaviour. How can we do it in compose?

Example [source]:

2


Solution

  • You can customise the ripple effect as follow:

    Modifier.clickable(
        interactionSource = remember { MutableInteractionSource() },
        indication = rememberRipple(bounded = false), // You can also change the color and radius of the ripple
        onClick = {}
    )