Text
High level element that displays text and provides semantics / accessibility information.
The default style uses the LocalTextStyle provided by the MaterialTheme / components. If you are setting your own style, you may want to consider first retrieving LocalTextStyle, and using TextStyle.copy to keep any theme defined attributes, only modifying the specific attributes you want to override.
For ease of use, commonly used parameters from TextStyle are also present here. The order of precedence is as follows:
If a parameter is explicitly set here (i.e, it is not
nullor TextUnit.Unspecified), then this parameter will always be used.If a parameter is not set, (
nullor TextUnit.Unspecified), then the corresponding value from style will be used instead.
Additionally, for color, if color is not set, and style does not have a color, then LocalContentColor will be used.
Parameters
the text to be displayed
the Modifier to be applied to this layout node
Color to apply to the text. If Color.Unspecified, and style has no color set, this will be LocalContentColor.
Enable auto sizing for this text composable. Finds the biggest font size that fits in the available space and lays the text out with this size. This performs multiple layout passes and can be slower than using a fixed font size. This takes precedence over sizes defined through fontSize and style. See TextAutoSize.
the size of glyphs to use when painting the text. See TextStyle.fontSize.
the typeface variant to use when drawing the letters (e.g., italic). See TextStyle.fontStyle.
the typeface thickness to use when painting the text (e.g., FontWeight.Bold).
the font family to be used when rendering the text. See TextStyle.fontFamily.
the amount of space to add between each letter. See TextStyle.letterSpacing.
the decorations to paint on the text (e.g., an underline). See TextStyle.textDecoration.
the alignment of the text within the lines of the paragraph. See TextStyle.textAlign.
line height for the Paragraph in TextUnit unit, e.g. SP or EM. See TextStyle.lineHeight.
how visual overflow should be handled.
callback that is executed when a new text layout is calculated. A TextLayoutResult object that callback provides contains paragraph information, size of the text, baselines and other details. The callback can be used to add additional decoration or functionality to the text. For example, to draw selection around the text.
style configuration for the text such as color, font, line height etc.
High level element that displays text and provides semantics / accessibility information.
The default style uses the LocalTextStyle provided by the MaterialTheme / components. If you are setting your own style, you may want to consider first retrieving LocalTextStyle, and using TextStyle.copy to keep any theme defined attributes, only modifying the specific attributes you want to override.
For ease of use, commonly used parameters from TextStyle are also present here. The order of precedence is as follows:
If a parameter is explicitly set here (i.e, it is not
nullor TextUnit.Unspecified), then this parameter will always be used.If a parameter is not set, (
nullor TextUnit.Unspecified), then the corresponding value from style will be used instead.
Parameters
the text to be displayed
the Modifier to be applied to this layout node
the ColorProducer that returns a Color. Useful when providing a color value that changes frequently without needing to recompose. Overrides the text color provided in style
Enable auto sizing for this text composable. Finds the biggest font size that fits in the available space and lays the text out with this size. This performs multiple layout passes and can be slower than using a fixed font size. This takes precedence over sizes defined through fontSize and style. See TextAutoSize.
the size of glyphs to use when painting the text. See TextStyle.fontSize.
the typeface variant to use when drawing the letters (e.g., italic). See TextStyle.fontStyle.
the typeface thickness to use when painting the text (e.g., FontWeight.Bold).
the font family to be used when rendering the text. See TextStyle.fontFamily.
the amount of space to add between each letter. See TextStyle.letterSpacing.
the decorations to paint on the text (e.g., an underline). See TextStyle.textDecoration.
the alignment of the text within the lines of the paragraph. See TextStyle.textAlign.
line height for the Paragraph in TextUnit unit, e.g. SP or EM. See TextStyle.lineHeight.
how visual overflow should be handled.
callback that is executed when a new text layout is calculated. A TextLayoutResult object that callback provides contains paragraph information, size of the text, baselines and other details. The callback can be used to add additional decoration or functionality to the text. For example, to draw selection around the text.
style configuration for the text such as color, font, line height etc.
High level element that displays text and provides semantics / accessibility information.
The default style uses the LocalTextStyle provided by the MaterialTheme / components. If you are setting your own style, you may want to consider first retrieving LocalTextStyle, and using TextStyle.copy to keep any theme defined attributes, only modifying the specific attributes you want to override.
For ease of use, commonly used parameters from TextStyle are also present here. The order of precedence is as follows:
If a parameter is explicitly set here (i.e, it is not
nullor TextUnit.Unspecified), then this parameter will always be used.If a parameter is not set, (
nullor TextUnit.Unspecified), then the corresponding value from style will be used instead.
Additionally, for color, if color is not set, and style does not have a color, then LocalContentColor will be used.
See an example of displaying text with links where links apply the styling from the theme:
Parameters
the text to be displayed
the Modifier to be applied to this layout node
Color to apply to the text. If Color.Unspecified, and style has no color set, this will be LocalContentColor.
Enable auto sizing for this text composable. Finds the biggest font size that fits in the available space and lays the text out with this size. This performs multiple layout passes and can be slower than using a fixed font size. This takes precedence over sizes defined through fontSize and style. See TextAutoSize.
the size of glyphs to use when painting the text. See TextStyle.fontSize.
the typeface variant to use when drawing the letters (e.g., italic). See TextStyle.fontStyle.
the typeface thickness to use when painting the text (e.g., FontWeight.Bold).
the font family to be used when rendering the text. See TextStyle.fontFamily.
the amount of space to add between each letter. See TextStyle.letterSpacing.
the decorations to paint on the text (e.g., an underline). See TextStyle.textDecoration.
the alignment of the text within the lines of the paragraph. See TextStyle.textAlign.
line height for the Paragraph in TextUnit unit, e.g. SP or EM. See TextStyle.lineHeight.
how visual overflow should be handled.
a map storing composables that replaces certain ranges of the text, used to insert composables into text layout. See InlineTextContent.
callback that is executed when a new text layout is calculated. A TextLayoutResult object that callback provides contains paragraph information, size of the text, baselines and other details. The callback can be used to add additional decoration or functionality to the text. For example, to draw selection around the text.
style configuration for the text such as color, font, line height etc.
Samples
androidx.compose.material3.samples.TextWithLinksHigh level element that displays text and provides semantics / accessibility information.
The default style uses the LocalTextStyle provided by the MaterialTheme / components. If you are setting your own style, you may want to consider first retrieving LocalTextStyle, and using TextStyle.copy to keep any theme defined attributes, only modifying the specific attributes you want to override.
For ease of use, commonly used parameters from TextStyle are also present here. The order of precedence is as follows:
If a parameter is explicitly set here (i.e, it is not
nullor TextUnit.Unspecified), then this parameter will always be used.If a parameter is not set, (
nullor TextUnit.Unspecified), then the corresponding value from style will be used instead.
See an example of displaying text with links where links apply the styling from the theme:
Parameters
the text to be displayed
the Modifier to be applied to this layout node
the ColorProducer that returns a Color. Useful when providing a color value that changes frequently without needing to recompose. Overrides the text color provided in style
Enable auto sizing for this text composable. Finds the biggest font size that fits in the available space and lays the text out with this size. This performs multiple layout passes and can be slower than using a fixed font size. This takes precedence over sizes defined through fontSize and style. See TextAutoSize.
the size of glyphs to use when painting the text. See TextStyle.fontSize.
the typeface variant to use when drawing the letters (e.g., italic). See TextStyle.fontStyle.
the typeface thickness to use when painting the text (e.g., FontWeight.Bold).
the font family to be used when rendering the text. See TextStyle.fontFamily.
the amount of space to add between each letter. See TextStyle.letterSpacing.
the decorations to paint on the text (e.g., an underline). See TextStyle.textDecoration.
the alignment of the text within the lines of the paragraph. See TextStyle.textAlign.
line height for the Paragraph in TextUnit unit, e.g. SP or EM. See TextStyle.lineHeight.
how visual overflow should be handled.
a map storing composables that replaces certain ranges of the text, used to insert composables into text layout. See InlineTextContent.
callback that is executed when a new text layout is calculated. A TextLayoutResult object that callback provides contains paragraph information, size of the text, baselines and other details. The callback can be used to add additional decoration or functionality to the text. For example, to draw selection around the text.
style configuration for the text such as color, font, line height etc.