Text

fun Text(text: String, modifier: Modifier = Modifier, style: TextStyle = LocalTextStyle.current, textAlign: TextAlign = TextAlign.Unspecified, lineHeight: TextUnit = TextUnit.Unspecified, fontSize: TextUnit = style.fontSize, letterSpacing: TextUnit = style.letterSpacing, fontWeight: FontWeight? = style.fontWeight, color: Color = Color.Unspecified, fontFamily: FontFamily? = style.fontFamily, singleLine: Boolean = false, minLines: Int = 1, maxLines: Int = if (singleLine) 1 else Int.MAX_VALUE, overflow: TextOverflow = TextOverflow.Clip)

A themable composable that displays text.

For interactive preview & code examples, visit Text Documentation.

Basic Example

Text("Hello, World!", fontWeight = FontWeight.Bold, fontSize = 16.sp)

Parameters

text

The text to be displayed.

modifier

Modifier to be applied to the text.

style

The style to be applied to the text.

textAlign

The alignment of the text.

lineHeight

The height of each line of text.

fontSize

The size of the text.

letterSpacing

The spacing between letters.

fontWeight

The weight of the text.

color

The color of the text.

fontFamily

The font family to be used.

singleLine

Whether the text should be displayed in a single line.

minLines

The minimum number of lines to display.

maxLines

The maximum number of lines to display.

overflow

How to handle text overflow.


fun Text(text: AnnotatedString, modifier: Modifier = Modifier, style: TextStyle = LocalTextStyle.current, textAlign: TextAlign = TextAlign.Unspecified, fontSize: TextUnit = style.fontSize, letterSpacing: TextUnit = style.letterSpacing, fontWeight: FontWeight? = style.fontWeight, color: Color = Color.Unspecified, lineHeight: TextUnit = TextUnit.Unspecified, fontFamily: FontFamily? = style.fontFamily, singleLine: Boolean = false, minLines: Int = 1, maxLines: Int = if (singleLine) 1 else Int.MAX_VALUE, overflow: TextOverflow = TextOverflow.Clip)

A themable composable that displays text.

For interactive preview & code examples, visit Text Documentation.

Basic Example

Text("Hello, World!", fontWeight = FontWeight.Bold, fontSize = 16.sp)

Parameters

text

The annotated text to be displayed.

modifier

Modifier to be applied to the text.

style

The style to be applied to the text.

textAlign

The alignment of the text.

fontSize

The size of the text.

letterSpacing

The spacing between letters.

fontWeight

The weight of the text.

color

The color of the text.

lineHeight

The height of each line of text.

fontFamily

The font family to be used.

singleLine

Whether the text should be displayed in a single line.

minLines

The minimum number of lines to display.

maxLines

The maximum number of lines to display.

overflow

How to handle text overflow.