Text

@Composable
fun Text(text: String, modifier: Modifier = Modifier, color: Color = Color.Unspecified, fontSize: TextUnit = TextUnit.Unspecified, fontStyle: FontStyle? = null, fontWeight: FontWeight? = null, fontFamily: FontFamily? = null, letterSpacing: TextUnit = TextUnit.Unspecified, textDecoration: TextDecoration? = null, textAlign: TextAlign? = null, lineHeight: TextUnit = TextUnit.Unspecified, overflow: TextOverflow = TextDefaults.overflow, softWrap: Boolean = true, maxLines: Int = TextDefaults.maxLines, minLines: Int = TextDefaults.minLines, onTextLayout: (TextLayoutResult) -> Unit? = null, style: TextStyle = LocalTextStyle.current)

Basic text component that integrates with Wild's content color system.

The default style uses the LocalTextStyle provided by parent components. If you are setting your own style, consider first retrieving LocalTextStyle and using TextStyle.copy to keep any inherited 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:

  • If a parameter is explicitly set here (i.e., it is not null or TextUnit.Unspecified), then this parameter will always be used.

  • If a parameter is not set, then the corresponding value from style will be used instead.

For color, if color is not set, and style does not have a color, then LocalContentColor will be used.

Since

0.6.0

Parameters

text

The text to display.

modifier

Modifier to apply to the text.

color

The color of the text. If Color.Unspecified, and style has no color set, this will be LocalContentColor.

fontSize

The size of glyphs to use when painting the text. See TextStyle.fontSize.

fontStyle

The typeface variant to use when drawing the letters (e.g., italic).

fontWeight

The typeface thickness to use when painting the text (e.g., FontWeight.Bold).

fontFamily

The font family to be used when rendering the text.

letterSpacing

The amount of space to add between each letter.

textDecoration

The decorations to paint on the text (e.g., an underline).

textAlign

The alignment of the text within the lines of the paragraph.

lineHeight

Line height for the text in TextUnit unit, e.g. SP or EM.

overflow

How visual overflow should be handled.

softWrap

Whether the text should break at soft line breaks.

maxLines

Maximum number of lines for the text to span.

minLines

Minimum number of lines for the text to span.

onTextLayout

Callback invoked when the text layout is calculated.

style

Style configuration for the text such as color, font, line height etc.


@Composable
fun Text(text: AnnotatedString, modifier: Modifier = Modifier, color: Color = Color.Unspecified, fontSize: TextUnit = TextUnit.Unspecified, fontStyle: FontStyle? = null, fontWeight: FontWeight? = null, fontFamily: FontFamily? = null, letterSpacing: TextUnit = TextUnit.Unspecified, textDecoration: TextDecoration? = null, textAlign: TextAlign? = null, lineHeight: TextUnit = TextUnit.Unspecified, overflow: TextOverflow = TextDefaults.overflow, softWrap: Boolean = true, maxLines: Int = TextDefaults.maxLines, minLines: Int = TextDefaults.minLines, onTextLayout: (TextLayoutResult) -> Unit? = null, style: TextStyle = LocalTextStyle.current)

Basic text component that displays AnnotatedString content with support for inline styling, spans, and links.

Integrates with Wild's content color system via LocalContentColor and supports typography inheritance via LocalTextStyle.

Since

0.6.0

Parameters

text

The AnnotatedString to display.

modifier

Modifier to apply to the text.

color

The color of the text. If Color.Unspecified, and style has no color set, this will be LocalContentColor.

fontSize

The size of glyphs to use when painting the text.

fontStyle

The typeface variant to use when drawing the letters.

fontWeight

The typeface thickness to use when painting the text.

fontFamily

The font family to be used when rendering the text.

letterSpacing

The amount of space to add between each letter.

textDecoration

The decorations to paint on the text.

textAlign

The alignment of the text within the lines of the paragraph.

lineHeight

Line height for the text.

overflow

How visual overflow should be handled.

softWrap

Whether the text should break at soft line breaks.

maxLines

Maximum number of lines for the text to span.

minLines

Minimum number of lines for the text to span.

onTextLayout

Callback invoked when the text layout is calculated.

style

Style configuration for the text.