Compose Modifier

stylusHoverIcon

Modifier that lets a developer define a pointer icon to display when a stylus is hovered over the element.

StylusHoverIconSample

@Sampled
@Composable
fun StylusHoverIconSample() {
    Box(
        Modifier.requiredSize(200.dp)
            .border(BorderStroke(2.dp, SolidColor(Color.Red)))
            .stylusHoverIcon(PointerIcon.Crosshair)
    ) {
        Text(text = "crosshair icon")
        Box(
            Modifier.padding(20.dp)
                .requiredSize(150.dp)
                .border(BorderStroke(2.dp, SolidColor(Color.Black)))
                .stylusHoverIcon(PointerIcon.Text)
        ) {
            Text(text = "text icon")
            Box(
                Modifier.padding(40.dp)
                    .requiredSize(100.dp)
                    .border(BorderStroke(2.dp, SolidColor(Color.Blue)))
                    .stylusHoverIcon(PointerIcon.Hand)
            ) {
                Text(text = "hand icon")
            }
        }
    }
}
Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: