Accessibility link - Jetpack Compose
In Jetpack Compose, starting from compose-ui 1.7.0
you can use LinkAnnotation.Url
of AnnotatedString
to add an inline link to the text.
Clicking on the link will automatically open it in the default browser.
val textWithLink = buildAnnotatedString {
append("Learn more about ")
// adding clickable url
withLink(
LinkAnnotation.Url(
url = "https://appt.org",
// adding style for the url
styles = TextLinkStyles(
style = SpanStyle(textDecoration = TextDecoration.Underline, color = Color.Blue)
)
)
) {
append("Appt")
}
}
Text(textWithLink)
Important: Starting from compose-ui 1.7.0
ClickableText
and pushUrlAnnotation
will be deprecated.