---
title: "getFirstLinkBounds"
description: "Returns the bounds of the first link matching the [predicate], or if that link spans multiple
lines, returns the bounds of the first line of the link.

A link in a Text composable is defined by a [LinkAnnotation] of the [AnnotatedString].

The bounds are in the text node's coordinate system.

You can pass an offset from within the bounds to injection methods to operate them on the link,
for example [TouchInjectionScope.click] or [MouseInjectionScope.moveTo]."
type: "function"
---

<div class='type'>Function</div>


<a id='references'></a>
<div class='sourceset sourceset-common'>Common</div>


```kotlin
fun SemanticsNodeInteraction.getFirstLinkBounds(
    predicate: (AnnotatedString.Range<LinkAnnotation>) -> Boolean = { true }
): Rect?
```


Returns the bounds of the first link matching the `predicate`, or if that link spans multiple
lines, returns the bounds of the first line of the link.

A link in a Text composable is defined by a `LinkAnnotation` of the `AnnotatedString`.

The bounds are in the text node's coordinate system.

You can pass an offset from within the bounds to injection methods to operate them on the link,
for example `TouchInjectionScope.click` or `MouseInjectionScope.moveTo`.



## Code Examples
### hoverFirstLinkInText
```kotlin
fun hoverFirstLinkInText() {
    // Example of hovering over the first link in test
    val firstLinkBounds =
        composeTestRule.onNodeWithText("YOUR_TEXT_WITH_LINK").getFirstLinkBounds {
            (it.item as? LinkAnnotation.Url)?.url == "YOUR_URL"
        }
    composeTestRule.onNodeWithText("YOUR_TEXT_WITH_LINK").performMouseInput {
        moveTo(firstLinkBounds!!.center)
    }
}
```

