By default, Android has ripple effect for all clickable objects. If you want to disable the ripple effect, you will need to wrap it in a LocalRippleTheme
.
private object NoRippleTheme : RippleTheme {
@Composable
override fun defaultColor() = Color.Unspecified
@Composable
override fun rippleAlpha(): RippleAlpha = RippleAlpha(0.0f, 0.0f, 0.0f, 0.0f)
}
CompositionLocalProvider(LocalRippleTheme provides NoRippleTheme) {
Button(
enabled = isEnabled,
onClick = {},
shape = RoundedCornerShape(12.dp),
interactionSource = interactionSource,
colors = ButtonDefaults.buttonColors(
containerColor = if (pressed) activeYellowColor else secondaryYellowColor,
disabledContainerColor = lightGreyColor
),
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 8.dp)
) {
Text(
text = "Primary Button without Ripple",
modifier = Modifier
.padding(vertical = 6.dp),
style = LocalTextStyle.current.merge(
TextStyle(
fontSize = 16.sp,
lineHeight = 22.sp,
color = if (isEnabled) secondaryTealColor else greyColor,
fontFamily = maisonNeueFamily,
fontWeight = FontWeight.Bold
)
)
)
}
}