# AnnotatedString.Builder

Artifact: [androidx.compose.ui:ui-text](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/text/AnnotatedString.kt+class:androidx.compose.ui.text.AnnotatedString.Builder) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0) Common/AllAndroid/JVM
- Cmn

  ```
  class AnnotatedString.Builder : Appendable
  ```

*** ** * ** ***

Builds an `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString` incrementally.

Implements `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.text/-appendable/index.html` for compatibility with standard text APIs.

```kotlin
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString

buildAnnotatedString {
    append("Hello")
    // push green text style so that any appended text will be green
    pushStyle(SpanStyle(color = Color.Green))
    // append new text, this text will be rendered as green
    append(" World")
    // pop the green style
    pop()
    // append a string without style
    append("!")
    // then style the last added word as red, exclamation mark will be red
    addStyle(SpanStyle(color = Color.Red), "Hello World".length, this.length)

    toAnnotatedString()
}
```

```kotlin
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.buildAnnotatedString

val words = listOf("Hello", "World")
buildAnnotatedString {
    // joinTo is a Kotlin stdlib function that takes an Appendable
    words.joinTo(this, separator = " ", postfix = "!")

    toAnnotatedString()
}
```

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder.BulletScope` Scope for a bullet list |

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#Builder(kotlin.Int)(capacity: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#Builder(androidx.compose.ui.text.AnnotatedString)(text: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString)` Create an `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder` instance using the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#Builder(kotlin.String)(text: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Create an `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder` instance using the given `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html`. | Cmn |

| ### Public functions |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#addBullet(androidx.compose.ui.text.Bullet,kotlin.Int,kotlin.Int)(bullet: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/Bullet, start: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, end: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Adds an annotation to draw a bullet. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#addBullet(androidx.compose.ui.text.Bullet,androidx.compose.ui.unit.TextUnit,kotlin.Int,kotlin.Int)(bullet: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/Bullet, indentation: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit, start: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, end: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Adds an annotation to draw a `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#addBullet(androidx.compose.ui.text.Bullet,androidx.compose.ui.unit.TextUnit,kotlin.Int,kotlin.Int)` together with a paragraph that adds an `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#addBullet(androidx.compose.ui.text.Bullet,androidx.compose.ui.unit.TextUnit,kotlin.Int,kotlin.Int)`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#addLink(androidx.compose.ui.text.LinkAnnotation.Clickable,kotlin.Int,kotlin.Int)(clickable: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/LinkAnnotation.Clickable, start: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, end: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Associates a clickable link with a range. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#addLink(androidx.compose.ui.text.LinkAnnotation.Url,kotlin.Int,kotlin.Int)(url: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/LinkAnnotation.Url, start: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, end: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Associates a URL link with a range. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#addStringAnnotation(kotlin.String,kotlin.String,kotlin.Int,kotlin.Int)(tag: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, annotation: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, start: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, end: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Associates a string annotation with a range. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#addStyle(androidx.compose.ui.text.ParagraphStyle,kotlin.Int,kotlin.Int)(style: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle, start: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, end: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Applies `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#addStyle(androidx.compose.ui.text.ParagraphStyle,kotlin.Int,kotlin.Int)` to the given range, creating a separate paragraph. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#addStyle(androidx.compose.ui.text.SpanStyle,kotlin.Int,kotlin.Int)(style: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/SpanStyle, start: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, end: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Applies `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#addStyle(androidx.compose.ui.text.SpanStyle,kotlin.Int,kotlin.Int)` to the given range. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#addTtsAnnotation(androidx.compose.ui.text.TtsAnnotation,kotlin.Int,kotlin.Int)(ttsAnnotation: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/TtsAnnotation, start: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, end: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Set a `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/TtsAnnotation` for the given range defined by `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#addTtsAnnotation(androidx.compose.ui.text.TtsAnnotation,kotlin.Int,kotlin.Int)` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#addTtsAnnotation(androidx.compose.ui.text.TtsAnnotation,kotlin.Int,kotlin.Int)`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ExperimentalTextApi [addUrlAnnotation](https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#addUrlAnnotation(androidx.compose.ui.text.UrlAnnotation,kotlin.Int,kotlin.Int))(urlAnnotation: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/UrlAnnotation, start: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, end: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` **This function is deprecated.** Use LinkAnnotation API for links instead | Cmn |
| `open https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#append(kotlin.Char)(char: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char/index.html)` | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#append(androidx.compose.ui.text.AnnotatedString)(text: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString)` Appends the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString` to this `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder`. | Cmn |
| `open https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#append(kotlin.CharSequence)(text: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?)` Appends `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#append(kotlin.CharSequence)` to this `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder` if non-null, and returns this `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#append(kotlin.String)(text: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Appends the given `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` to this `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#append(androidx.compose.ui.text.AnnotatedString,kotlin.Int,kotlin.Int)(text: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString, start: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, end: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Appends the range of `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#append(androidx.compose.ui.text.AnnotatedString,kotlin.Int,kotlin.Int)` between `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#append(androidx.compose.ui.text.AnnotatedString,kotlin.Int,kotlin.Int)` (inclusive) and `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#append(androidx.compose.ui.text.AnnotatedString,kotlin.Int,kotlin.Int)` (exclusive) to this `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder`. | Cmn |
| `open https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#append(kotlin.CharSequence,kotlin.Int,kotlin.Int)(text: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?, start: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, end: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Appends the range of `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#append(kotlin.CharSequence,kotlin.Int,kotlin.Int)` between `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#append(kotlin.CharSequence,kotlin.Int,kotlin.Int)` (inclusive) and `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#append(kotlin.CharSequence,kotlin.Int,kotlin.Int)` (exclusive) to this `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder` if non-null, and returns this `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pop()()` Ends the style or annotation that was added via a push operation before. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pop(kotlin.Int)(index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Ends the styles or annotation up to and `including` the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pushStyle(androidx.compose.ui.text.SpanStyle)` or `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pushStringAnnotation(kotlin.String,kotlin.String)` that returned the given index. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pushBullet(androidx.compose.ui.text.Bullet)(bullet: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/Bullet)` Applies the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pushBullet(androidx.compose.ui.text.Bullet)` annotation to any appended text until a corresponding `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pop()` is called. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pushLink(androidx.compose.ui.text.LinkAnnotation)(link: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/LinkAnnotation)` Attach the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/LinkAnnotation` to any appended text until a corresponding `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pop()` is called. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pushStringAnnotation(kotlin.String,kotlin.String)(tag: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, annotation: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Attach the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pushStringAnnotation(kotlin.String,kotlin.String)` to any appended text until a corresponding `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pop()` is called. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pushStyle(androidx.compose.ui.text.ParagraphStyle)(style: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle)` Applies the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle` to any appended text until a corresponding `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pop()` is called. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pushStyle(androidx.compose.ui.text.SpanStyle)(style: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/SpanStyle)` Applies the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/SpanStyle` to any appended text until a corresponding `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pop()` is called. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pushTtsAnnotation(androidx.compose.ui.text.TtsAnnotation)(ttsAnnotation: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/TtsAnnotation)` Attach the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pushTtsAnnotation(androidx.compose.ui.text.TtsAnnotation)` to any appended text until a corresponding `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pop()` is called. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ExperimentalTextApi [pushUrlAnnotation](https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pushUrlAnnotation(androidx.compose.ui.text.UrlAnnotation))(urlAnnotation: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/UrlAnnotation)` **This function is deprecated.** Use LinkAnnotation API for links instead | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#toAnnotatedString()()` Constructs an `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString` based on the configurations applied to the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder`. | Cmn |
| `R` | `<R : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#withBulletList(androidx.compose.ui.unit.TextUnit,androidx.compose.ui.text.Bullet,kotlin.Function1)(indentation: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit, bullet: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/Bullet, block: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder.BulletScope.() -> R)` Creates a bullet list which allows to define a common `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#withBulletList(androidx.compose.ui.unit.TextUnit,androidx.compose.ui.text.Bullet,kotlin.Function1)` and a `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#withBulletList(androidx.compose.ui.unit.TextUnit,androidx.compose.ui.text.Bullet,kotlin.Function1)` for evey bullet list item created inside the list. | Cmn |
| `R` | `<R : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder.BulletScope.https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#(androidx.compose.ui.text.AnnotatedString.Builder.BulletScope).withBulletListItem(androidx.compose.ui.text.Bullet,kotlin.Function1)( bullet: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/Bullet?, block: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder.() -> R )` Creates a bullet list item around the content produced by the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#(androidx.compose.ui.text.AnnotatedString.Builder.BulletScope).withBulletListItem(androidx.compose.ui.text.Bullet,kotlin.Function1)`. | Cmn |

| ### Public properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#length()` Returns the length of the `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html`. | Cmn |

| ### Extension functions |
|---|---|---|
| `inline R` | `<R : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder.https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#(androidx.compose.ui.text.AnnotatedString.Builder).withAnnotation(androidx.compose.ui.text.TtsAnnotation,kotlin.Function1)( ttsAnnotation: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/TtsAnnotation, crossinline block: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder.() -> R )` Pushes an `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/TtsAnnotation` to the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder`, executes `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/package-summary#(androidx.compose.ui.text.AnnotatedString.Builder).withAnnotation(androidx.compose.ui.text.TtsAnnotation,kotlin.Function1)` and then pops the annotation. | Cmn |
| `inline R` | `@https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ExperimentalTextApi <R : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder.[withAnnotation](https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#(androidx.compose.ui.text.AnnotatedString.Builder).withAnnotation(androidx.compose.ui.text.UrlAnnotation,kotlin.Function1))( urlAnnotation: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/UrlAnnotation, crossinline block: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder.() -> R )` **This function is deprecated.** Use LinkAnnotation API for links instead | Cmn |
| `inline R` | `<R : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder.https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#(androidx.compose.ui.text.AnnotatedString.Builder).withAnnotation(kotlin.String,kotlin.String,kotlin.Function1)( tag: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, annotation: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, crossinline block: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder.() -> R )` Pushes an annotation to the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder`, executes `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/package-summary#(androidx.compose.ui.text.AnnotatedString.Builder).withAnnotation(kotlin.String,kotlin.String,kotlin.Function1)` and then pops the annotation. | Cmn |
| `inline R` | `<R : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder.https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#(androidx.compose.ui.text.AnnotatedString.Builder).withLink(androidx.compose.ui.text.LinkAnnotation,kotlin.Function1)( link: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/LinkAnnotation, block: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder.() -> R )` Pushes a `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/LinkAnnotation` to the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder`, executes `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/package-summary#(androidx.compose.ui.text.AnnotatedString.Builder).withLink(androidx.compose.ui.text.LinkAnnotation,kotlin.Function1)` and then pops the annotation. | Cmn |
| `inline R` | `<R : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder.https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#(androidx.compose.ui.text.AnnotatedString.Builder).withStyle(androidx.compose.ui.text.ParagraphStyle,kotlin.Function1)( style: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle, crossinline block: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder.() -> R )` Pushes `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/package-summary#(androidx.compose.ui.text.AnnotatedString.Builder).withStyle(androidx.compose.ui.text.ParagraphStyle,kotlin.Function1)` to the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder`, executes `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/package-summary#(androidx.compose.ui.text.AnnotatedString.Builder).withStyle(androidx.compose.ui.text.ParagraphStyle,kotlin.Function1)` and then pops the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/package-summary#(androidx.compose.ui.text.AnnotatedString.Builder).withStyle(androidx.compose.ui.text.ParagraphStyle,kotlin.Function1)`. | Cmn |
| `inline R` | `<R : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder.https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#(androidx.compose.ui.text.AnnotatedString.Builder).withStyle(androidx.compose.ui.text.SpanStyle,kotlin.Function1)(style: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/SpanStyle, block: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder.() -> R)` Pushes `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/package-summary#(androidx.compose.ui.text.AnnotatedString.Builder).withStyle(androidx.compose.ui.text.SpanStyle,kotlin.Function1)` to the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder`, executes `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/package-summary#(androidx.compose.ui.text.AnnotatedString.Builder).withStyle(androidx.compose.ui.text.SpanStyle,kotlin.Function1)` and then pops the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/package-summary#(androidx.compose.ui.text.AnnotatedString.Builder).withStyle(androidx.compose.ui.text.SpanStyle,kotlin.Function1)`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder.https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#(androidx.compose.ui.text.AnnotatedString.Builder).appendInlineContent(kotlin.String,kotlin.String)( id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, alternateText: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html )` Used to insert composables into the text layout. | Cmn |

## Public constructors

### Builder

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
Builder(capacity: Int = 16)
```

| Parameters |
|---|---|
| `capacity: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html = 16` | initial capacity for the internal buffer |

### Builder

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
Builder(text: AnnotatedString)
```

Create an `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder` instance using the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString`.

### Builder

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
Builder(text: String)
```

Create an `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder` instance using the given `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html`.

## Public functions

### addBullet

Cmn Added in [1.9.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.9.0)

```
fun addBullet(bullet: Bullet, start: Int, end: Int): Unit
```

Adds an annotation to draw a bullet. Unlike another overload, this one doesn't add a separate `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle`. As so for bullet to be rendered, make sure it starts on a separate line by adding a newline before or wrapping with a `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle`.

For a convenient API to create a bullet list check `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#withBulletList(androidx.compose.ui.unit.TextUnit,androidx.compose.ui.text.Bullet,kotlin.Function1)`.

| Parameters |
|---|---|
| `bullet: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/Bullet` | a bullet to draw before the text |
| `start: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the inclusive starting offset of the range |
| `end: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the exclusive end offset of the range |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#withBulletList(androidx.compose.ui.unit.TextUnit,androidx.compose.ui.text.Bullet,kotlin.Function1)` |   |

### addBullet

Cmn Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

```
fun addBullet(bullet: Bullet, indentation: TextUnit, start: Int, end: Int): Unit
```

Adds an annotation to draw a `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#addBullet(androidx.compose.ui.text.Bullet,androidx.compose.ui.unit.TextUnit,kotlin.Int,kotlin.Int)` together with a paragraph that adds an `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#addBullet(androidx.compose.ui.text.Bullet,androidx.compose.ui.unit.TextUnit,kotlin.Int,kotlin.Int)`.

| Parameters |
|---|---|
| `bullet: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/Bullet` | a bullet to draw before the text |
| `indentation: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit` | indentation that is added to the paragraph. Note that this indentation should be large enough to fit a bullet and a padding between the bullet and beginning of the paragraph |
| `start: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the inclusive starting offset of the range |
| `end: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the exclusive end offset of the range |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#withBulletList(androidx.compose.ui.unit.TextUnit,androidx.compose.ui.text.Bullet,kotlin.Function1)` |   |

### addLink

Cmn Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.7.0)

```
fun addLink(clickable: LinkAnnotation.Clickable, start: Int, end: Int): Unit
```

Associates a clickable link with a range.

Clicking the text triggers a `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/LinkInteractionListener` with `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#addLink(androidx.compose.ui.text.LinkAnnotation.Clickable,kotlin.Int,kotlin.Int)`.

Screen readers present clickables in different ways, such as using a links menu or audio cues.

| Parameters |
|---|---|
| `clickable: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/LinkAnnotation.Clickable` | click metadata |
| `start: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | inclusive start offset |
| `end: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | exclusive end offset |

### addLink

Cmn Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.7.0)

```
fun addLink(url: LinkAnnotation.Url, start: Int, end: Int): Unit
```

Associates a URL link with a range.

Clicking the text opens the URL using `https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/UriHandler`.

Screen readers present URLs in different ways, such as using a links menu or audio cues.

| Parameters |
|---|---|
| `url: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/LinkAnnotation.Url` | the target URL |
| `start: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | inclusive start offset |
| `end: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | exclusive end offset |

### addStringAnnotation

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun addStringAnnotation(tag: String, annotation: String, start: Int, end: Int): Unit
```

Associates a string annotation with a range.

```kotlin
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.buildAnnotatedString

buildAnnotatedString {
    append("link: Jetpack Compose")
    // attach a string annotation that stores a URL to the text "Jetpack Compose".
    addStringAnnotation(
        tag = "URL",
        annotation = "https://developer.android.com/jetpack/compose",
        start = 6,
        end = 21,
    )
}
```

| Parameters |
|---|---|
| `tag: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | tag to identify the annotation |
| `annotation: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | string annotation value |
| `start: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | inclusive start offset |
| `end: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | exclusive end offset |

### addStyle

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun addStyle(style: ParagraphStyle, start: Int, end: Int): Unit
```

Applies `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#addStyle(androidx.compose.ui.text.ParagraphStyle,kotlin.Int,kotlin.Int)` to the given range, creating a separate paragraph.

Paragraph ranges must follow paragraph arrangement rules. See `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString` class documentation for details and examples.

| Parameters |
|---|---|
| `style: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle` to apply |
| `start: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | inclusive start offset |
| `end: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | exclusive end offset |

### addStyle

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun addStyle(style: SpanStyle, start: Int, end: Int): Unit
```

Applies `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#addStyle(androidx.compose.ui.text.SpanStyle,kotlin.Int,kotlin.Int)` to the given range.

| Parameters |
|---|---|
| `style: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/SpanStyle` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/SpanStyle` to apply |
| `start: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | inclusive start offset |
| `end: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | exclusive end offset |

### addTtsAnnotation

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun addTtsAnnotation(ttsAnnotation: TtsAnnotation, start: Int, end: Int): Unit
```

Set a `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/TtsAnnotation` for the given range defined by `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#addTtsAnnotation(androidx.compose.ui.text.TtsAnnotation,kotlin.Int,kotlin.Int)` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#addTtsAnnotation(androidx.compose.ui.text.TtsAnnotation,kotlin.Int,kotlin.Int)`.

```kotlin
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.buildAnnotatedString

buildAnnotatedString {
    append("link: Jetpack Compose")
    // attach a string annotation that stores a URL to the text "Jetpack Compose".
    addStringAnnotation(
        tag = "URL",
        annotation = "https://developer.android.com/jetpack/compose",
        start = 6,
        end = 21,
    )
}
```

| Parameters |
|---|---|
| `ttsAnnotation: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/TtsAnnotation` | an object that stores text to speech metadata that intended for the TTS engine. |
| `start: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the inclusive starting offset of the range |
| `end: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the exclusive end offset of the range |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString#getStringAnnotations(kotlin.String,kotlin.Int,kotlin.Int)` |   |

### addUrlAnnotation

Cmn Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.3.0) Deprecated in [1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.7.0)

```
@ExperimentalTextApi
fun [addUrlAnnotation](https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#addUrlAnnotation(androidx.compose.ui.text.UrlAnnotation,kotlin.Int,kotlin.Int))(urlAnnotation: UrlAnnotation, start: Int, end: Int): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
> Use LinkAnnotation API for links instead, use this instead:
>
> ```kotlin
> addLink(, start, end)
> ```

Set a `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/UrlAnnotation` for the given range defined by `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#addUrlAnnotation(androidx.compose.ui.text.UrlAnnotation,kotlin.Int,kotlin.Int)` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#addUrlAnnotation(androidx.compose.ui.text.UrlAnnotation,kotlin.Int,kotlin.Int)`. URLs may be treated specially by screen readers, including being identified while reading text with an audio icon or being summarized in a links menu.

```kotlin
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.buildAnnotatedString

buildAnnotatedString {
    append("link: Jetpack Compose")
    // attach a string annotation that stores a URL to the text "Jetpack Compose".
    addStringAnnotation(
        tag = "URL",
        annotation = "https://developer.android.com/jetpack/compose",
        start = 6,
        end = 21,
    )
}
```

| Parameters |
|---|---|
| `urlAnnotation: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/UrlAnnotation` | A `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/UrlAnnotation` object that stores the URL being linked to. |
| `start: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the inclusive starting offset of the range |
| `end: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the exclusive end offset of the range |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString#getStringAnnotations(kotlin.String,kotlin.Int,kotlin.Int)` |   |

### append

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
open fun append(char: Char): AnnotatedString.Builder
```

### append

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun append(text: AnnotatedString): Unit
```

Appends the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString` to this `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder`.

| Parameters |
|---|---|
| `text: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString` | the text to append |

### append

Cmn Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.4.0)

```
open fun append(text: CharSequence?): AnnotatedString.Builder
```

Appends `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#append(kotlin.CharSequence)` to this `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder` if non-null, and returns this `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder`.

If `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#append(kotlin.CharSequence)` is an `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString`, all spans and annotations will be copied over as well. No other subtypes of `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html` will be treated specially. For example, any platform-specific types, such as `SpannedString` on Android, will only have their text copied and any other information held in the sequence, such as Android `Span`s, will be dropped.

| Parameters |
|---|---|
| `text: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?` | the text to append |

### append

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun append(text: String): Unit
```

Appends the given `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` to this `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder`.

| Parameters |
|---|---|
| `text: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the text to append |

### append

Cmn Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.4.0)

```
fun append(text: AnnotatedString, start: Int, end: Int): Unit
```

Appends the range of `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#append(androidx.compose.ui.text.AnnotatedString,kotlin.Int,kotlin.Int)` between `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#append(androidx.compose.ui.text.AnnotatedString,kotlin.Int,kotlin.Int)` (inclusive) and `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#append(androidx.compose.ui.text.AnnotatedString,kotlin.Int,kotlin.Int)` (exclusive) to this `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder`. All spans and annotations from `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#append(androidx.compose.ui.text.AnnotatedString,kotlin.Int,kotlin.Int)` between `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#append(androidx.compose.ui.text.AnnotatedString,kotlin.Int,kotlin.Int)` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#append(androidx.compose.ui.text.AnnotatedString,kotlin.Int,kotlin.Int)` will be copied over as well.

| Parameters |
|---|---|
| `text: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString` | the text to append |
| `start: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index of the first character in `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#append(androidx.compose.ui.text.AnnotatedString,kotlin.Int,kotlin.Int)` to copy over (inclusive). |
| `end: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index after the last character in `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#append(androidx.compose.ui.text.AnnotatedString,kotlin.Int,kotlin.Int)` to copy over (exclusive). |

### append

Cmn Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.4.0)

```
open fun append(text: CharSequence?, start: Int, end: Int): AnnotatedString.Builder
```

Appends the range of `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#append(kotlin.CharSequence,kotlin.Int,kotlin.Int)` between `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#append(kotlin.CharSequence,kotlin.Int,kotlin.Int)` (inclusive) and `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#append(kotlin.CharSequence,kotlin.Int,kotlin.Int)` (exclusive) to this `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder` if non-null, and returns this `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder`.

If `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#append(kotlin.CharSequence,kotlin.Int,kotlin.Int)` is an `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString`, all spans and annotations from `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#append(kotlin.CharSequence,kotlin.Int,kotlin.Int)` between `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#append(kotlin.CharSequence,kotlin.Int,kotlin.Int)` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#append(kotlin.CharSequence,kotlin.Int,kotlin.Int)` will be copied over as well. No other subtypes of `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html` will be treated specially. For example, any platform-specific types, such as `SpannedString` on Android, will only have their text copied and any other information held in the sequence, such as Android `Span`s, will be dropped.

| Parameters |
|---|---|
| `text: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?` | the text to append |
| `start: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index of the first character in `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#append(kotlin.CharSequence,kotlin.Int,kotlin.Int)` to copy over (inclusive). |
| `end: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index after the last character in `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#append(kotlin.CharSequence,kotlin.Int,kotlin.Int)` to copy over (exclusive). |

### pop

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun pop(): Unit
```

Ends the style or annotation that was added via a push operation before.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pushStyle(androidx.compose.ui.text.SpanStyle)` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pushStringAnnotation(kotlin.String,kotlin.String)` |   |

### pop

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun pop(index: Int): Unit
```

Ends the styles or annotation up to and `including` the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pushStyle(androidx.compose.ui.text.SpanStyle)` or `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pushStringAnnotation(kotlin.String,kotlin.String)` that returned the given index.

| Parameters |
|---|---|
| `index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the result of the a previous `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pushStyle(androidx.compose.ui.text.SpanStyle)` or `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pushStringAnnotation(kotlin.String,kotlin.String)` in order to pop to |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pop(kotlin.Int)` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pushStyle(androidx.compose.ui.text.SpanStyle)` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pushStringAnnotation(kotlin.String,kotlin.String)` |   |

### pushBullet

Cmn Added in [1.9.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.9.0)

```
fun pushBullet(bullet: Bullet): Int
```

Applies the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pushBullet(androidx.compose.ui.text.Bullet)` annotation to any appended text until a corresponding `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pop()` is called. For bullet to be rendered, make sure it starts on a separate line by either adding a newline before or by wrapping with a `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle`.

For a convenient API to create a bullet list check `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#withBulletList(androidx.compose.ui.unit.TextUnit,androidx.compose.ui.text.Bullet,kotlin.Function1)`.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#withBulletList(androidx.compose.ui.unit.TextUnit,androidx.compose.ui.text.Bullet,kotlin.Function1)` |   |

### pushLink

Cmn Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.7.0)

```
fun pushLink(link: LinkAnnotation): Int
```

Attach the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/LinkAnnotation` to any appended text until a corresponding `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pop()` is called.

| Parameters |
|---|---|
| `link: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/LinkAnnotation` | A `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/LinkAnnotation` object that stores the URL or clickable tag being linked to. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString#getStringAnnotations(kotlin.String,kotlin.Int,kotlin.Int)` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Range` |   |

### pushStringAnnotation

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun pushStringAnnotation(tag: String, annotation: String): Int
```

Attach the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pushStringAnnotation(kotlin.String,kotlin.String)` to any appended text until a corresponding `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pop()` is called.

```kotlin
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.buildAnnotatedString

buildAnnotatedString {
    // push a string annotation to be applied to any appended text after this point.
    pushStringAnnotation("ParagrapLabel", "paragraph1")
    // append a paragraph, the annotation "paragraph1" is attached
    append("Paragraph One\n")
    // pop the annotation
    pop()
    // append new paragraph
    append("Paragraph Two\n")

    toAnnotatedString()
}
```

| Parameters |
|---|---|
| `tag: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the tag used to distinguish annotations |
| `annotation: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the string annotation attached on this AnnotatedString |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString#getStringAnnotations(kotlin.String,kotlin.Int,kotlin.Int)` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Range` |   |

### pushStyle

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun pushStyle(style: ParagraphStyle): Int
```

Applies the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle` to any appended text until a corresponding `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pop()` is called.

```kotlin
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.ParagraphStyle
import androidx.compose.ui.unit.sp

with(AnnotatedString.Builder()) {
    // push a ParagraphStyle to be applied to any appended text after this point.
    pushStyle(ParagraphStyle(lineHeight = 18.sp))
    // append a paragraph which will have lineHeight 18.sp
    append("Paragraph One\n")
    // pop the ParagraphStyle
    pop()
    // append new paragraph, this paragraph will not have the line height defined.
    append("Paragraph Two\n")

    toAnnotatedString()
}
```

| Parameters |
|---|---|
| `style: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle` | ParagraphStyle to be applied |

### pushStyle

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun pushStyle(style: SpanStyle): Int
```

Applies the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/SpanStyle` to any appended text until a corresponding `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pop()` is called.

```kotlin
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString

buildAnnotatedString {
    // push green text color so that any appended text will be rendered green
    pushStyle(SpanStyle(color = Color.Green))
    // append string, this text will be rendered green
    append("Hello")
    // pop the green text style
    pop()
    // append new string, this string will be default color
    append(" World")

    toAnnotatedString()
}
```

| Parameters |
|---|---|
| `style: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/SpanStyle` | SpanStyle to be applied |

### pushTtsAnnotation

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun pushTtsAnnotation(ttsAnnotation: TtsAnnotation): Int
```

Attach the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pushTtsAnnotation(androidx.compose.ui.text.TtsAnnotation)` to any appended text until a corresponding `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pop()` is called.

```kotlin
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.buildAnnotatedString

buildAnnotatedString {
    // push a string annotation to be applied to any appended text after this point.
    pushStringAnnotation("ParagrapLabel", "paragraph1")
    // append a paragraph, the annotation "paragraph1" is attached
    append("Paragraph One\n")
    // pop the annotation
    pop()
    // append new paragraph
    append("Paragraph Two\n")

    toAnnotatedString()
}
```

| Parameters |
|---|---|
| `ttsAnnotation: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/TtsAnnotation` | an object that stores text to speech metadata that intended for the TTS engine. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString#getStringAnnotations(kotlin.String,kotlin.Int,kotlin.Int)` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Range` |   |

### pushUrlAnnotation

Cmn Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.3.0) Deprecated in [1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.7.0)

```
@ExperimentalTextApi
fun [pushUrlAnnotation](https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pushUrlAnnotation(androidx.compose.ui.text.UrlAnnotation))(urlAnnotation: UrlAnnotation): Int
```

> [!CAUTION]
> **This function is deprecated.**   
> Use LinkAnnotation API for links instead, use this instead:
>
> ```kotlin
> pushLink(, start, end)
> ```

Attach the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/UrlAnnotation` to any appended text until a corresponding `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pop()` is called.

```kotlin
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.buildAnnotatedString

buildAnnotatedString {
    // push a string annotation to be applied to any appended text after this point.
    pushStringAnnotation("ParagrapLabel", "paragraph1")
    // append a paragraph, the annotation "paragraph1" is attached
    append("Paragraph One\n")
    // pop the annotation
    pop()
    // append new paragraph
    append("Paragraph Two\n")

    toAnnotatedString()
}
```

| Parameters |
|---|---|
| `urlAnnotation: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/UrlAnnotation` | A `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/UrlAnnotation` object that stores the URL being linked to. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString#getStringAnnotations(kotlin.String,kotlin.Int,kotlin.Int)` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Range` |   |

### toAnnotatedString

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun toAnnotatedString(): AnnotatedString
```

Constructs an `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString` based on the configurations applied to the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder`.

### withBulletList

Cmn

```
fun <R : Any> withBulletList(
    indentation: TextUnit = Bullet.DefaultIndentation,
    bullet: Bullet = Bullet.Default,
    block: AnnotatedString.Builder.BulletScope.() -> R
): R
```

Creates a bullet list which allows to define a common `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#withBulletList(androidx.compose.ui.unit.TextUnit,androidx.compose.ui.text.Bullet,kotlin.Function1)` and a `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#withBulletList(androidx.compose.ui.unit.TextUnit,androidx.compose.ui.text.Bullet,kotlin.Function1)` for evey bullet list item created inside the list.

Note that when nesting the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#withBulletList(androidx.compose.ui.unit.TextUnit,androidx.compose.ui.text.Bullet,kotlin.Function1)` calls, the indentation inside the nested list will be a combination of all indentations in the nested chain. For example,

```kotlin
withBulletList(10.sp) {
  withBulletList(15.sp) {
    // items indentation 25.sp
  }
}
```

### AnnotatedString.Builder.BulletScope.withBulletListItem

Cmn Artifact: [androidx.compose.ui:ui-text](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/text/AnnotatedString.kt+function:withBulletListItem) Added in [1.9.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.9.0)

```
fun <R : Any> AnnotatedString.Builder.BulletScope.withBulletListItem(
    bullet: Bullet? = null,
    block: AnnotatedString.Builder.() -> R
): R
```

Creates a bullet list item around the content produced by the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#(androidx.compose.ui.text.AnnotatedString.Builder.BulletScope).withBulletListItem(androidx.compose.ui.text.Bullet,kotlin.Function1)`. The list item creates a separate paragraph with the indentation to the bullet defined by the preceding `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#withBulletList(androidx.compose.ui.unit.TextUnit,androidx.compose.ui.text.Bullet,kotlin.Function1)` calls.

```kotlin
import androidx.compose.foundation.text.BasicText
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.Bullet
import androidx.compose.ui.text.buildAnnotatedString

BasicText(
    buildAnnotatedString {
        append("Not a bullet item")
        withBulletList {
            withBulletListItem { append("Item 1") }
            withBulletList { withBulletListItem { append("Nested item 2") } }
            withBulletListItem { append("Item 3") }
        }
    }
)
```

| Parameters |
|---|---|
| `bullet: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/Bullet? = null` | defines the bullet to be drawn |
| `block: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder.() -> R` | function to be executed |

## Public properties

### length

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
val length: Int
```

Returns the length of the `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html`.

## Extension functions

### AnnotatedString.Builder.withAnnotation

Cmn Artifact: [androidx.compose.ui:ui-text](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/text/AnnotatedString.kt+function:withAnnotation)

```
inline fun <R : Any> AnnotatedString.Builder.withAnnotation(
    ttsAnnotation: TtsAnnotation,
    crossinline block: AnnotatedString.Builder.() -> R
): R
```

Pushes an `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/TtsAnnotation` to the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder`, executes `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/package-summary#(androidx.compose.ui.text.AnnotatedString.Builder).withAnnotation(androidx.compose.ui.text.TtsAnnotation,kotlin.Function1)` and then pops the annotation.

| Parameters |
|---|---|
| `ttsAnnotation: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/TtsAnnotation` | an object that stores text to speech metadata that intended for the TTS engine. |
| `crossinline block: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder.() -> R` | function to be executed |

| Returns |
|---|---|
| `R` | result of the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/package-summary#(androidx.compose.ui.text.AnnotatedString.Builder).withAnnotation(androidx.compose.ui.text.TtsAnnotation,kotlin.Function1)` |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pushStringAnnotation(kotlin.String,kotlin.String)` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pop()` |   |

### AnnotatedString.Builder.withAnnotation

Cmn Artifact: [androidx.compose.ui:ui-text](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/text/AnnotatedString.kt+function:withAnnotation)

```
@ExperimentalTextApi
inline fun <R : Any> AnnotatedString.Builder.[withAnnotation](https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#(androidx.compose.ui.text.AnnotatedString.Builder).withAnnotation(androidx.compose.ui.text.UrlAnnotation,kotlin.Function1))(
    urlAnnotation: UrlAnnotation,
    crossinline block: AnnotatedString.Builder.() -> R
): R
```

> [!CAUTION]
> **This function is deprecated.**   
> Use LinkAnnotation API for links instead, use this instead:
>
> ```kotlin
> withLink(, block)
> ```

Pushes an `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/UrlAnnotation` to the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder`, executes `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/package-summary#(androidx.compose.ui.text.AnnotatedString.Builder).withAnnotation(androidx.compose.ui.text.UrlAnnotation,kotlin.Function1)` and then pops the annotation.

| Parameters |
|---|---|
| `urlAnnotation: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/UrlAnnotation` | A `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/UrlAnnotation` object that stores the URL being linked to. |
| `crossinline block: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder.() -> R` | function to be executed |

| Returns |
|---|---|
| `R` | result of the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/package-summary#(androidx.compose.ui.text.AnnotatedString.Builder).withAnnotation(androidx.compose.ui.text.UrlAnnotation,kotlin.Function1)` |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pushStringAnnotation(kotlin.String,kotlin.String)` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pop()` |   |

### AnnotatedString.Builder.withAnnotation

Cmn Artifact: [androidx.compose.ui:ui-text](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/text/AnnotatedString.kt+function:withAnnotation)

```
inline fun <R : Any> AnnotatedString.Builder.withAnnotation(
    tag: String,
    annotation: String,
    crossinline block: AnnotatedString.Builder.() -> R
): R
```

Pushes an annotation to the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder`, executes `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/package-summary#(androidx.compose.ui.text.AnnotatedString.Builder).withAnnotation(kotlin.String,kotlin.String,kotlin.Function1)` and then pops the annotation.

| Parameters |
|---|---|
| `tag: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the tag used to distinguish annotations |
| `annotation: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the string annotation attached on this AnnotatedString |
| `crossinline block: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder.() -> R` | function to be executed |

| Returns |
|---|---|
| `R` | result of the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/package-summary#(androidx.compose.ui.text.AnnotatedString.Builder).withAnnotation(kotlin.String,kotlin.String,kotlin.Function1)` |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pushStringAnnotation(kotlin.String,kotlin.String)` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pop()` |   |

### AnnotatedString.Builder.withLink

Cmn Artifact: [androidx.compose.ui:ui-text](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/text/AnnotatedString.kt+function:withLink)

```
inline fun <R : Any> AnnotatedString.Builder.withLink(
    link: LinkAnnotation,
    block: AnnotatedString.Builder.() -> R
): R
```

Pushes a `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/LinkAnnotation` to the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder`, executes `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/package-summary#(androidx.compose.ui.text.AnnotatedString.Builder).withLink(androidx.compose.ui.text.LinkAnnotation,kotlin.Function1)` and then pops the annotation.

```kotlin
import androidx.compose.foundation.text.BasicText
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.LinkAnnotation
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.TextLinkStyles
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.withLink
import androidx.compose.ui.unit.sp

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

```kotlin
import androidx.compose.foundation.text.BasicText
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.LinkAnnotation
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.TextLinkStyles
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.text.withLink
import androidx.compose.ui.unit.sp

// Display a link in the text that gets an underline when hovered
BasicText(
    buildAnnotatedString {
        append("Build better apps faster with ")
        val link =
            LinkAnnotation.Url(
                "https://developer.android.com/jetpack/compose",
                TextLinkStyles(
                    style = SpanStyle(color = Color.Blue),
                    hoveredStyle = SpanStyle(textDecoration = TextDecoration.Underline),
                ),
            )
        withLink(link) { append("Jetpack Compose") }
    }
)
```

```kotlin
import androidx.compose.foundation.text.BasicText
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.LinkAnnotation
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.TextLinkStyles
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.withLink
import androidx.compose.ui.unit.sp

// Display a link in the text and log metrics whenever user clicks on it. In that case we handle
// the link using openUri method of the LocalUriHandler
val uriHandler = LocalUriHandler.current
BasicText(
    buildAnnotatedString {
        append("Build better apps faster with ")
        val link =
            LinkAnnotation.Url(
                "https://developer.android.com/jetpack/compose",
                TextLinkStyles(SpanStyle(color = Color.Blue)),
            ) {
                val url = (it as LinkAnnotation.Url).url
                // log some metrics
                uriHandler.openUri(url)
            }
        withLink(link) { append("Jetpack Compose") }
    }
)
```

| Parameters |
|---|---|
| `link: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/LinkAnnotation` | A `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/LinkAnnotation` object representing a clickable part of the text |
| `block: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder.() -> R` | function to be executed |

| Returns |
|---|---|
| `R` | result of the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/package-summary#(androidx.compose.ui.text.AnnotatedString.Builder).withLink(androidx.compose.ui.text.LinkAnnotation,kotlin.Function1)` |

### AnnotatedString.Builder.withStyle

Cmn Artifact: [androidx.compose.ui:ui-text](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/text/AnnotatedString.kt+function:withStyle)

```
inline fun <R : Any> AnnotatedString.Builder.withStyle(
    style: ParagraphStyle,
    crossinline block: AnnotatedString.Builder.() -> R
): R
```

Pushes `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/package-summary#(androidx.compose.ui.text.AnnotatedString.Builder).withStyle(androidx.compose.ui.text.ParagraphStyle,kotlin.Function1)` to the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder`, executes `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/package-summary#(androidx.compose.ui.text.AnnotatedString.Builder).withStyle(androidx.compose.ui.text.ParagraphStyle,kotlin.Function1)` and then pops the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/package-summary#(androidx.compose.ui.text.AnnotatedString.Builder).withStyle(androidx.compose.ui.text.ParagraphStyle,kotlin.Function1)`.

```kotlin
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.withStyle

buildAnnotatedString {
    withStyle(SpanStyle(color = Color.Green)) {
        // green text style will be applied to all text in this block
        append("Hello")
    }
    toAnnotatedString()
}
```

| Parameters |
|---|---|
| `style: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/SpanStyle` to be applied |
| `crossinline block: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder.() -> R` | function to be executed |

| Returns |
|---|---|
| `R` | result of the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/package-summary#(androidx.compose.ui.text.AnnotatedString.Builder).withStyle(androidx.compose.ui.text.ParagraphStyle,kotlin.Function1)` |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pushStyle(androidx.compose.ui.text.SpanStyle)` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pop()` |   |

### AnnotatedString.Builder.withStyle

Cmn Artifact: [androidx.compose.ui:ui-text](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/text/AnnotatedString.kt+function:withStyle)

```
inline fun <R : Any> AnnotatedString.Builder.withStyle(style: SpanStyle, block: AnnotatedString.Builder.() -> R): R
```

Pushes `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/package-summary#(androidx.compose.ui.text.AnnotatedString.Builder).withStyle(androidx.compose.ui.text.SpanStyle,kotlin.Function1)` to the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder`, executes `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/package-summary#(androidx.compose.ui.text.AnnotatedString.Builder).withStyle(androidx.compose.ui.text.SpanStyle,kotlin.Function1)` and then pops the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/package-summary#(androidx.compose.ui.text.AnnotatedString.Builder).withStyle(androidx.compose.ui.text.SpanStyle,kotlin.Function1)`.

```kotlin
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.withStyle

buildAnnotatedString {
    withStyle(SpanStyle(color = Color.Green)) {
        // green text style will be applied to all text in this block
        append("Hello")
    }
    toAnnotatedString()
}
```

| Parameters |
|---|---|
| `style: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/SpanStyle` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/SpanStyle` to be applied |
| `block: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder.() -> R` | function to be executed |

| Returns |
|---|---|
| `R` | result of the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/package-summary#(androidx.compose.ui.text.AnnotatedString.Builder).withStyle(androidx.compose.ui.text.SpanStyle,kotlin.Function1)` |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pushStyle(androidx.compose.ui.text.SpanStyle)` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString.Builder#pop()` |   |

### AnnotatedString.Builder.appendInlineContent

Cmn Artifact: [androidx.compose.foundation:foundation](https://developer.android.com/jetpack/androidx/releases/compose-foundation) [View Source](https://cs.android.com/search?q=file:androidx/compose/foundation/text/InlineTextContent.kt+function:appendInlineContent)

```
fun AnnotatedString.Builder.appendInlineContent(
    id: String,
    alternateText: String = REPLACEMENT_CHAR
): Unit
```

Used to insert composables into the text layout. This method can be used together with the inlineContent parameter of `https://developer.android.com/reference/kotlin/androidx/compose/foundation/text/BasicText.composable#BasicText(kotlin.String,androidx.compose.ui.Modifier,androidx.compose.ui.text.TextStyle,kotlin.Function1,androidx.compose.ui.text.style.TextOverflow,kotlin.Boolean,kotlin.Int,kotlin.Int,androidx.compose.ui.graphics.ColorProducer,androidx.compose.foundation.text.TextAutoSize)`. It will append the `https://developer.android.com/reference/kotlin/androidx/compose/foundation/text/package-summary#(androidx.compose.ui.text.AnnotatedString.Builder).appendInlineContent(kotlin.String,kotlin.String)` to this `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString` and also mark this range of text to be replaced by a composable. `https://developer.android.com/reference/kotlin/androidx/compose/foundation/text/BasicText.composable#BasicText(kotlin.String,androidx.compose.ui.Modifier,androidx.compose.ui.text.TextStyle,kotlin.Function1,androidx.compose.ui.text.style.TextOverflow,kotlin.Boolean,kotlin.Int,kotlin.Int,androidx.compose.ui.graphics.ColorProducer,androidx.compose.foundation.text.TextAutoSize)` will try to find an `https://developer.android.com/reference/kotlin/androidx/compose/foundation/text/InlineTextContent` in the map defined by inlineContent whose key equals to `https://developer.android.com/reference/kotlin/androidx/compose/foundation/text/package-summary#(androidx.compose.ui.text.AnnotatedString.Builder).appendInlineContent(kotlin.String,kotlin.String)`, and it will use the `https://developer.android.com/reference/kotlin/androidx/compose/foundation/text/InlineTextContent#children()` to replace this range of text.

```kotlin
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.text.BasicText
import androidx.compose.foundation.text.InlineTextContent
import androidx.compose.foundation.text.appendInlineContent
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.Placeholder
import androidx.compose.ui.text.PlaceholderVerticalAlign
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.unit.em

val myId = "inlineContent"
val text = buildAnnotatedString {
    append("Hello")
    // Append a placeholder string "[myBox]" and attach an annotation "inlineContent" on it.
    appendInlineContent(myId, "[myBox]")
}

val inlineContent =
    mapOf(
        Pair(
            // This tells the [BasicText] to replace the placeholder string "[myBox]" by
            // the composable given in the [InlineTextContent] object.
            myId,
            InlineTextContent(
                // Placeholder tells text layout the expected size and vertical alignment of
                // children composable.
                Placeholder(
                    width = 0.5.em,
                    height = 0.5.em,
                    placeholderVerticalAlign = PlaceholderVerticalAlign.AboveBaseline,
                )
            ) {
                // This [Box] will fill maximum size, which is specified by the [Placeholder]
                // above. Notice the width and height in [Placeholder] are specified in
                // TextUnit,
                // and are converted into pixel by text layout.
                Box(modifier = Modifier.fillMaxSize().background(color = Color.Red))
            },
        )
    )

BasicText(text = text, inlineContent = inlineContent)
```

| Parameters |
|---|---|
| `id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The id used to look up the `https://developer.android.com/reference/kotlin/androidx/compose/foundation/text/InlineTextContent`, it is referred by the inlineContent parameter of `https://developer.android.com/reference/kotlin/androidx/compose/foundation/text/BasicText.composable#BasicText(kotlin.String,androidx.compose.ui.Modifier,androidx.compose.ui.text.TextStyle,kotlin.Function1,androidx.compose.ui.text.style.TextOverflow,kotlin.Boolean,kotlin.Int,kotlin.Int,androidx.compose.ui.graphics.ColorProducer,androidx.compose.foundation.text.TextAutoSize)` to replace the `https://developer.android.com/reference/kotlin/androidx/compose/foundation/text/package-summary#(androidx.compose.ui.text.AnnotatedString.Builder).appendInlineContent(kotlin.String,kotlin.String)` to the corresponding composable. |
| `alternateText: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html = REPLACEMENT_CHAR` | The text to be replaced by the inline content. It's displayed when the inlineContent parameter of `https://developer.android.com/reference/kotlin/androidx/compose/foundation/text/BasicText.composable#BasicText(kotlin.String,androidx.compose.ui.Modifier,androidx.compose.ui.text.TextStyle,kotlin.Function1,androidx.compose.ui.text.style.TextOverflow,kotlin.Boolean,kotlin.Int,kotlin.Int,androidx.compose.ui.graphics.ColorProducer,androidx.compose.foundation.text.TextAutoSize)` doesn't contain `https://developer.android.com/reference/kotlin/androidx/compose/foundation/text/package-summary#(androidx.compose.ui.text.AnnotatedString.Builder).appendInlineContent(kotlin.String,kotlin.String)`. Accessibility features will also use this text to describe the inline content. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/kotlin/androidx/compose/foundation/text/package-summary#(androidx.compose.ui.text.AnnotatedString.Builder).appendInlineContent(kotlin.String,kotlin.String)` has zero length. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/text/InlineTextContent` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/text/BasicText.composable#BasicText(kotlin.String,androidx.compose.ui.Modifier,androidx.compose.ui.text.TextStyle,kotlin.Function1,androidx.compose.ui.text.style.TextOverflow,kotlin.Boolean,kotlin.Int,kotlin.Int,androidx.compose.ui.graphics.ColorProducer,androidx.compose.foundation.text.TextAutoSize)` |   |