StreamingText

fun StreamingText(text: String, animate: Boolean = true, chunkDelayMs: Long = 30, content: @Composable (displayedText: String) -> Unit = { displayedText -> RichText(text = displayedText) })

A composable that wraps content and provides streaming animation. Progressively reveals text content word-by-word and whitespace chunk-by-chunk.

Behavior when animate is true:

  • Every change to the text animates progressively

  • If the change is new text (doesn't start with previous), animates from the beginning

  • If the change is a continuation (next text starts with previous text), continues from current position

Behavior when animate is false:

  • Displays full text immediately

  • If transitioning from true to false mid-animation, completes the current animation first

Parameters

text

The full text content to display

animate

Whether to animate the text reveal. If false, displays full text immediately.

chunkDelayMs

Delay in milliseconds between each chunk reveal. Lower values result in faster animation.

content

The composable content that will receive the animated text as displayedText