Compose Unstyled 2.0 is out! Check the official announcement blog ->

ColoredIndication

A customizable indication effect that displays colored overlays based on user interactions like hover, press, focus, and drag.

API Reference

rememberColoredIndication

Parameter Type Description
hoveredColor Color Color overlay to display when the component is hovered
pressedColor Color Color overlay to display when the component is pressed
focusedColor Color Color overlay to display when the component is focused
draggedColor Color Color overlay to display when the component is being dragged
showAnimationSpec AnimationSpec<Float>
hideAnimationSpec AnimationSpec<Float>
color Color Base color to use for all interaction states
draggedAlpha Float Alpha value for the dragged state. Defaults to 0.16f
focusedAlpha Float Alpha value for the focused state. Defaults to 0.1f
hoveredAlpha Float Alpha value for the hovered state. Defaults to 0.08f
pressedAlpha Float Alpha value for the pressed state. Defaults to 0.1f

ColoredIndication

Parameter Type Description
hoveredColor Color Color overlay to display when the component is hovered
pressedColor Color Color overlay to display when the component is pressed
focusedColor Color Color overlay to display when the component is focused
draggedColor Color Color overlay to display when the component is being dragged
animationSpecEnter AnimationSpec<Float>
animationSpecExit AnimationSpec<Float>

Installation

implementation("com.composables:composeunstyled-colored-indication")

Code Examples

Basic Usage

Use rememberColoredIndication to create a colored indication effect with a single base color:

import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.dp
import com.composeunstyled.UnstyledButton
import androidx.compose.foundation.text.BasicText
import com.composeunstyled.theme.rememberColoredIndication

@Composable
fun ColoredIndicationBasicExample() {
    val interactionSource = remember { MutableInteractionSource() }

    UnstyledButton(
        onClick = { },
        backgroundColor = Color(0xFF3B82F6),
        shape = RoundedCornerShape(8.dp),
        contentPadding = PaddingValues(horizontal = 16.dp, vertical = 12.dp),
        indication = rememberColoredIndication(color = Color.White),
        interactionSource = interactionSource
    ) {
        BasicText("Hover or Click", style = TextStyle(color = Color.White))
    }
}
import com.composeunstyled.UnstyledButton
import com.composeunstyled.theme.rememberColoredIndication
UnstyledButton(
    onClick = { },
    indication = rememberColoredIndication(color = Color.White),
) {
    BasicText("Hover or Click")
}