LinkAnnotation

Class

Common
abstract class LinkAnnotation private constructor() : AnnotatedString.Annotation

An annotation that represents a clickable part of the text.

Properties

Common
abstract val linkInteractionListener: LinkInteractionListener?

Interaction listener triggered when user interacts with this link.

Common
abstract val styles: TextLinkStyles?

Style configuration for this link in different states.

Code Examples

AnnotatedStringWithLinkSample

@Composable
fun AnnotatedStringWithLinkSample() {
    // Display a link in the text
    BasicText(
        buildAnnotatedString {
            append("Build better apps faster with ")
            withLink(
                LinkAnnotation.Url(
                    "https://developer.android.com/jetpack/compose",
                    TextLinkStyles(style = SpanStyle(color = Color.Blue)),
                )
            ) {
                append("Jetpack Compose")
            }
        }
    )
}