BasicText

Functions summary

Unit
@Composable
BasicText(
    text: String,
    styleProvider: TextStyleScope.() -> Unit,
    modifier: Modifier,
    onTextLayout: ((TextLayoutResult) -> Unit)?,
    overflow: TextOverflow,
    softWrap: Boolean,
    maxLines: Int,
    minLines: Int,
    autoSize: TextAutoSize?
)

Displays text with style resolved dynamically from a lambda.

Cmn
Unit
@Composable
BasicText(
    text: AnnotatedString,
    styleProvider: TextStyleScope.() -> Unit,
    modifier: Modifier,
    onTextLayout: ((TextLayoutResult) -> Unit)?,
    overflow: TextOverflow,
    softWrap: Boolean,
    maxLines: Int,
    minLines: Int,
    inlineContent: Map<String, InlineTextContent>,
    autoSize: TextAutoSize?
)

Displays text with style resolved dynamically from a lambda.

Cmn
Unit
@Composable
BasicText(
    text: String,
    modifier: Modifier,
    style: TextStyle,
    onTextLayout: ((TextLayoutResult) -> Unit)?,
    overflow: TextOverflow,
    softWrap: Boolean,
    maxLines: Int,
    minLines: Int,
    color: ColorProducer?,
    autoSize: TextAutoSize?
)

Displays text with semantics and accessibility information.

Cmn
Unit
@Composable
BasicText(
    text: AnnotatedString,
    modifier: Modifier,
    style: TextStyle,
    onTextLayout: ((TextLayoutResult) -> Unit)?,
    overflow: TextOverflow,
    softWrap: Boolean,
    maxLines: Int,
    minLines: Int,
    inlineContent: Map<String, InlineTextContent>,
    color: ColorProducer?,
    autoSize: TextAutoSize?
)

Displays text with semantics and accessibility information.

Cmn

Functions

@Composable
fun BasicText(
    text: String,
    styleProvider: TextStyleScope.() -> Unit,
    modifier: Modifier = Modifier,
    onTextLayout: ((TextLayoutResult) -> Unit)? = null,
    overflow: TextOverflow = TextOverflow.Clip,
    softWrap: Boolean = true,
    maxLines: Int = Int.MAX_VALUE,
    minLines: Int = 1,
    autoSize: TextAutoSize? = null
): Unit

Displays text with style resolved dynamically from a lambda.

For theme integration, use Material androidx.compose.material3.Text.

Use this overload when style depends on state and changes frequently. Using a lambda prevents full recomposition when the style changes, deferring evaluation to the layout phase:

  • State reads within styleProvider are observed during measurement and trigger a measure pass when invalidated, skipping recomposition.

  • Changes to layout-affecting attributes recalculate text layout and invalidate drawing, whereas changes to draw-only attributes reuse the cached text layout and invalidate drawing.

Parameters
text: String

text to display

styleProvider: TextStyleScope.() -> Unit

lambda with TextStyleScope receiver configuring text attributes

modifier: Modifier = Modifier

for this layout

onTextLayout: ((TextLayoutResult) -> Unit)? = null

callback run when a new text layout is calculated. The TextLayoutResult parameter contains paragraph information, size, baselines, and other details. Use this callback to add decoration or functionality, such as drawing selection. Note that when using this overload, TextLayoutResult.layoutInput's TextStyle is not guaranteed to contain the real draw attributes configured in styleProvider

overflow: TextOverflow = TextOverflow.Clip

handling visual overflow

softWrap: Boolean = true

whether to wrap text at soft line breaks. When true, wraps text to the next line when it exceeds layout bounds. When false, positions text as if there was unlimited horizontal space, which may cause it to clip or overflow according to overflow

maxLines: Int = Int.MAX_VALUE

maximum number of visible lines. If the text exceeds this value, it is truncated according to overflow and softWrap. Requires 1 <= minLines<= maxLines

minLines: Int = 1

minimum number of visible lines. Requires 1 <= minLines<= maxLines

autoSize: TextAutoSize? = null

configuration for automatic font size adjustment to fit available space. Warning: Auto-sizing runs multiple layout passes and may affect performance. Takes precedence over sizes defined in styleProvider

@Composable
fun BasicText(
    text: AnnotatedString,
    styleProvider: TextStyleScope.() -> Unit,
    modifier: Modifier = Modifier,
    onTextLayout: ((TextLayoutResult) -> Unit)? = null,
    overflow: TextOverflow = TextOverflow.Clip,
    softWrap: Boolean = true,
    maxLines: Int = Int.MAX_VALUE,
    minLines: Int = 1,
    inlineContent: Map<String, InlineTextContent> = mapOf(),
    autoSize: TextAutoSize? = null
): Unit

Displays text with style resolved dynamically from a lambda.

For theme integration, use Material androidx.compose.material3.Text.

Use this overload when style depends on state and changes frequently. Using a lambda prevents full recomposition when the style changes, deferring evaluation to the layout phase:

  • State reads within styleProvider are observed during measurement and trigger a measure pass when invalidated, skipping recomposition.

  • Changes to layout-affecting attributes recalculate text layout and invalidate drawing, whereas changes to draw-only attributes reuse the cached text layout and invalidate drawing.

Parameters
text: AnnotatedString

text to display

styleProvider: TextStyleScope.() -> Unit

lambda with TextStyleScope receiver configuring text attributes

modifier: Modifier = Modifier

for this layout

onTextLayout: ((TextLayoutResult) -> Unit)? = null

callback run when a new text layout is calculated. The TextLayoutResult parameter contains paragraph information, size, baselines, and other details. Use this callback to add decoration or functionality, such as drawing selection. Note that when using this overload, TextLayoutResult.layoutInput's TextStyle is not guaranteed to contain the real draw attributes configured in styleProvider

overflow: TextOverflow = TextOverflow.Clip

handling visual overflow

softWrap: Boolean = true

whether to wrap text at soft line breaks. When true, wraps text to the next line when it exceeds layout bounds. When false, positions text as if there was unlimited horizontal space, which may cause it to clip or overflow according to overflow

maxLines: Int = Int.MAX_VALUE

maximum number of visible lines. If the text exceeds this value, it is truncated according to overflow and softWrap. Requires 1 <= minLines<= maxLines

minLines: Int = 1

minimum number of visible lines. Requires 1 <= minLines<= maxLines

inlineContent: Map<String, InlineTextContent> = mapOf()

map storing InlineTextContent composables that replace specified ranges of text, embedding them in the layout

autoSize: TextAutoSize? = null

configuration for automatic font size adjustment to fit available space. Warning: Auto-sizing runs multiple layout passes and may affect performance. Takes precedence over sizes defined in styleProvider

@Composable
fun BasicText(
    text: String,
    modifier: Modifier = Modifier,
    style: TextStyle = TextStyle.Default,
    onTextLayout: ((TextLayoutResult) -> Unit)? = null,
    overflow: TextOverflow = TextOverflow.Clip,
    softWrap: Boolean = true,
    maxLines: Int = Int.MAX_VALUE,
    minLines: Int = 1,
    color: ColorProducer? = null,
    autoSize: TextAutoSize? = null
): Unit

Displays text with semantics and accessibility information.

For theme integration, use Material androidx.compose.material3.Text.

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.text.BasicText
import androidx.compose.foundation.text.TextAutoSize
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp

Box(modifier = Modifier.size(200.dp)) {
    // The text will find the biggest available font size that fits in the box.
    BasicText(text = "Hello World", autoSize = TextAutoSize.StepBased())
}
Parameters
text: String

text to display

modifier: Modifier = Modifier

for this layout

style: TextStyle = TextStyle.Default

configuration

onTextLayout: ((TextLayoutResult) -> Unit)? = null

callback run when a new text layout is calculated. The TextLayoutResult parameter contains paragraph information, size, baselines, and other details. Use this callback to add decoration or functionality, such as drawing selection

overflow: TextOverflow = TextOverflow.Clip

handling visual overflow

softWrap: Boolean = true

whether to wrap text at soft line breaks. When true, wraps text to the next line when it exceeds layout bounds. When false, positions text as if there was unlimited horizontal space, which may cause it to clip or overflow according to overflow

maxLines: Int = Int.MAX_VALUE

maximum number of visible lines. If the text exceeds this value, it is truncated according to overflow and softWrap. Requires 1 <= minLines<= maxLines

minLines: Int = 1

minimum number of visible lines. Requires 1 <= minLines<= maxLines

color: ColorProducer? = null

to override style color

autoSize: TextAutoSize? = null

configuration for automatic font size adjustment to fit available space. Warning: Auto-sizing runs multiple layout passes and may affect performance. Takes precedence over sizes defined in style

@Composable
fun BasicText(
    text: AnnotatedString,
    modifier: Modifier = Modifier,
    style: TextStyle = TextStyle.Default,
    onTextLayout: ((TextLayoutResult) -> Unit)? = null,
    overflow: TextOverflow = TextOverflow.Clip,
    softWrap: Boolean = true,
    maxLines: Int = Int.MAX_VALUE,
    minLines: Int = 1,
    inlineContent: Map<String, InlineTextContent> = mapOf(),
    color: ColorProducer? = null,
    autoSize: TextAutoSize? = null
): Unit

Displays text with semantics and accessibility information.

For theme integration, use Material androidx.compose.material3.Text.

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.text.BasicText
import androidx.compose.foundation.text.TextAutoSize
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp

Box(modifier = Modifier.size(200.dp)) {
    // The text will find the biggest available font size that fits in the box.
    BasicText(text = "Hello World", autoSize = TextAutoSize.StepBased())
}
Parameters
text: AnnotatedString

text to display

modifier: Modifier = Modifier

for this layout

style: TextStyle = TextStyle.Default

configuration

onTextLayout: ((TextLayoutResult) -> Unit)? = null

callback run when a new text layout is calculated. The TextLayoutResult parameter contains paragraph information, size, baselines, and other details. Use this callback to add decoration or functionality, such as drawing selection

overflow: TextOverflow = TextOverflow.Clip

handling visual overflow

softWrap: Boolean = true

whether to wrap text at soft line breaks. When true, wraps text to the next line when it exceeds layout bounds. When false, positions text as if there was unlimited horizontal space, which may cause it to clip or overflow according to overflow

maxLines: Int = Int.MAX_VALUE

maximum number of visible lines. If the text exceeds this value, it is truncated according to overflow and softWrap. Requires 1 <= minLines<= maxLines

minLines: Int = 1

minimum number of visible lines. Requires 1 <= minLines<= maxLines

inlineContent: Map<String, InlineTextContent> = mapOf()

map storing InlineTextContent composables that replace specified ranges of text, embedding them in the layout

color: ColorProducer? = null

to override style color

autoSize: TextAutoSize? = null

configuration for automatic font size adjustment to fit available space. Warning: Auto-sizing runs multiple layout passes and may affect performance. Takes precedence over sizes defined in style