Composable Function

BasicText

Displays text with semantics and accessibility information.

TextAutoSizeBasicTextSample

/** Sample of using [TextAutoSize.StepBased] to auto-size text. */
@Sampled
@Composable
fun TextAutoSizeBasicTextSample() {
    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())
    }
}

/**
 * Example of a custom [TextAutoSize] implementation that uses a list of [TextUnit] presets to find
 * the fitting font size.
 */
Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: