BasicText

Functions summary

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<StringInlineTextContent>,
    color: ColorProducer?,
    autoSize: TextAutoSize?
)

Displays text with semantics and accessibility information.

Cmn

Functions

@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<StringInlineTextContent> = 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<StringInlineTextContent> = 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