We just launched Compose Examples featuring over 150+ components! Check it out →

pointerHoverIcon

Common

Modifier in Compose Ui

Modifier that lets a developer define a pointer icon to display when the cursor is hovered over the element. When [overrideDescendants] is set to true, descendants cannot override the pointer icon using this modifier.

Last updated:

Installation

dependencies {
   implementation("androidx.compose.ui:ui:1.8.0-alpha04")
}

Overloads

@Stable
fun Modifier.pointerHoverIcon(icon: PointerIcon, overrideDescendants: Boolean = false)

Parameters

namedescription
iconThe icon to set
overrideDescendantswhen false (by default) descendants are able to set their own pointer icon. If true, no descendants under this parent are eligible to change the icon (it will be set to the this [the parent's] icon).

Code Example

PointerIconSample

@Composable
fun PointerIconSample() {
    Column(Modifier.pointerHoverIcon(PointerIcon.Crosshair)) {
        SelectionContainer {
            Column {
                Text("Selectable text")
                Text(
                    modifier = Modifier.pointerHoverIcon(PointerIcon.Hand, true),
                    text = "Selectable text with hand"
                )
            }
        }
        Text("Just text with global pointerIcon")
    }
}
by @alexstyl