ColoredIndication
A customizable indication effect that displays colored overlays based on user interactions like hover, press, focus, and drag.
@Composable
fun rememberColoredIndication(
color: Color,
draggedAlpha: Float = 0.16f,
focusedAlpha: Float = 0.1f,
hoveredAlpha: Float = 0.08f,
pressedAlpha: Float = 0.1f,
): IndicationNodeFactory
| Parameter | Description |
|---|---|
color | Base color to use for all interaction states |
draggedAlpha | Alpha value for the dragged state. Defaults to 0.16f |
focusedAlpha | Alpha value for the focused state. Defaults to 0.1f |
hoveredAlpha | Alpha value for the hovered state. Defaults to 0.08f |
pressedAlpha | Alpha value for the pressed state. Defaults to 0.1f |
class ColoredIndication(
hoveredColor: Color,
pressedColor: Color,
focusedColor: Color,
draggedColor: Color,
) : IndicationNodeFactory
| Parameter | Description |
|---|---|
hoveredColor | Color overlay to display when the component is hovered |
pressedColor | Color overlay to display when the component is pressed |
focusedColor | Color overlay to display when the component is focused |
draggedColor | Color overlay to display when the component is being dragged |
Code Examples
Basic Usage
Use rememberColoredIndication to create a colored indication effect with a single base color:
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
import com.composeunstyled.Button
import com.composeunstyled.theme.rememberColoredIndication
Button(
onClick = { },
indication = rememberColoredIndication(color = Color.White),
) {
Text("Hover or Click")
}
