Interface

TextAutoSize

Interface used by Text composables to override text size to automatically grow or shrink text to fill the layout bounds.

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: