# stylusHoverIcon

Common/AllAndroid/JVM

## Functions summary

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier.https://developer.android.com/reference/kotlin/androidx/compose/ui/input/pointer/stylusHoverIcon.modifier#(androidx.compose.ui.Modifier).stylusHoverIcon(androidx.compose.ui.input.pointer.PointerIcon,kotlin.Boolean,androidx.compose.ui.node.DpTouchBoundsExpansion)( icon: https://developer.android.com/reference/kotlin/androidx/compose/ui/input/pointer/PointerIcon, overrideDescendants: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, touchBoundsExpansion: https://developer.android.com/reference/kotlin/androidx/compose/ui/node/DpTouchBoundsExpansion? )` Modifier that lets a developer define a pointer icon to display when a stylus is hovered over the element. | Cmn |

## Functions

### Modifier.stylusHoverIcon

Cmn Artifact: [androidx.compose.ui:ui](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/input/pointer/PointerIcon.kt+function:stylusHoverIcon) Added in [1.8.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.8.0)

```
fun Modifier.stylusHoverIcon(
    icon: PointerIcon,
    overrideDescendants: Boolean = false,
    touchBoundsExpansion: DpTouchBoundsExpansion? = null
): Modifier
```

Modifier that lets a developer define a pointer icon to display when a stylus is hovered over the element. When `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/pointer/package-summary#(androidx.compose.ui.Modifier).stylusHoverIcon(androidx.compose.ui.input.pointer.PointerIcon,kotlin.Boolean,androidx.compose.ui.node.DpTouchBoundsExpansion)` is set to true, descendants cannot override the pointer icon using this modifier.

```kotlin
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.requiredSize
import androidx.compose.material3.Text
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.input.pointer.PointerIcon
import androidx.compose.ui.input.pointer.stylusHoverIcon
import androidx.compose.ui.unit.dp

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")
        }
    }
}
```

| Parameters |
|---|---|
| `icon: https://developer.android.com/reference/kotlin/androidx/compose/ui/input/pointer/PointerIcon` | the icon to set |
| `overrideDescendants: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = false` | when 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). |
| `touchBoundsExpansion: https://developer.android.com/reference/kotlin/androidx/compose/ui/node/DpTouchBoundsExpansion? = null` | amount by which the element's bounds is expanded |