OudsBodyText

fun OudsBodyText(text: String, modifier: Modifier = Modifier, size: OudsBodyTextSize = OudsBodyTextDefaults.Size, weight: OudsTextWeight = OudsBodyTextDefaults.Weight, color: Color = OudsBodyTextDefaults.Color, textAlign: TextAlign? = null, lineHeight: TextUnit = TextUnit.Unspecified, overflow: TextOverflow = TextOverflow.Clip, softWrap: Boolean = true, maxLines: Int = Int.MAX_VALUE, minLines: Int = 1, onTextLayout: (TextLayoutResult) -> Unit? = null)

Body styles are designed for everyday text content such as paragraphs, descriptions, and informational messages. They prioritize readability and provide a comfortable reading experience across all screen sizes. Multiple size options allow content importance to be expressed while maintaining consistency. Their typography automatically scales across breakpoints to support responsive layouts.

An overload accepting annotated string is available for rich text formatting.

Design

NameBody
Version1.0.0

Parameters

text

Text to be displayed.

modifier

Modifier applied to the body text.

size

Size of the body text.

weight

Weight of the body text.

color

Color of the body text.

textAlign

Alignment of the text within the lines of the paragraph. See TextStyle.textAlign.

lineHeight

Line height for the Paragraph in TextUnit unit, e.g. SP or EM. See TextStyle.lineHeight.

overflow

How visual overflow should be handled.

softWrap

Whether the text should break at soft line breaks. If false, the glyphs in the text will be positioned as if there was unlimited horizontal space. If softWrap is false, overflow and TextAlign may have unexpected effects.

maxLines

An optional maximum number of lines for the text to span, wrapping if necessary. If the text exceeds the given number of lines, it will be truncated according to overflow and softWrap. It is required that 1 <= minLines<= maxLines.

minLines

The minimum height in terms of minimum number of visible lines. It is required that 1 <= minLines<= maxLines.

onTextLayout

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.

Samples

OudsBodyText(
    modifier = Modifier.padding(OudsTheme.spaces.fixed.small),
    text = "Body",
    size = OudsBodyTextSize.Medium,
    weight = OudsTextWeight.Moderate
)

fun OudsBodyText(text: OudsAnnotatedBodyText, modifier: Modifier = Modifier, size: OudsBodyTextSize = OudsBodyTextDefaults.Size, weight: OudsTextWeight = OudsBodyTextDefaults.Weight, color: Color = OudsBodyTextDefaults.Color, textAlign: TextAlign? = null, lineHeight: TextUnit = TextUnit.Unspecified, overflow: TextOverflow = TextOverflow.Clip, softWrap: Boolean = true, maxLines: Int = Int.MAX_VALUE, minLines: Int = 1, onTextLayout: (TextLayoutResult) -> Unit = {})

Body styles are designed for everyday text content such as paragraphs, descriptions, and informational messages. They prioritize readability and provide a comfortable reading experience across all screen sizes. Multiple size options allow content importance to be expressed while maintaining consistency. Their typography automatically scales across breakpoints to support responsive layouts.

An overload accepting plain text is available for simple text without formatting.

Design

NameBody
Version1.0.0

Parameters

text

Text to be displayed. Note: Use rich text in compliance with guidelines and accessibility criteria.

modifier

Modifier applied to the body text.

size

Size of the body text.

weight

Weight of the body text.

color

Color of the body text.

textAlign

Alignment of the text within the lines of the paragraph. See TextStyle.textAlign.

lineHeight

Line height for the Paragraph in TextUnit unit, e.g. SP or EM. See TextStyle.lineHeight.

overflow

How visual overflow should be handled.

softWrap

Whether the text should break at soft line breaks. If false, the glyphs in the text will be positioned as if there was unlimited horizontal space. If softWrap is false, overflow and TextAlign may have unexpected effects.

maxLines

An optional maximum number of lines for the text to span, wrapping if necessary. If the text exceeds the given number of lines, it will be truncated according to overflow and softWrap. It is required that 1 <= minLines<= maxLines.

minLines

The minimum height in terms of minimum number of visible lines. It is required that 1 <= minLines<= maxLines.

onTextLayout

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.

Samples

val highlightColor = OudsTheme.colorScheme.content.brandPrimary
OudsBodyText(
    modifier = Modifier.padding(OudsTheme.spaces.fixed.small),
    text = buildOudsAnnotatedBodyText {
        withStrong {
            withColor(color = highlightColor) { append("Important update") }
        }
        append(", see details ")
        withLink(link = OudsLinkAnnotation.Url("https://example.com/details")) { append("here") }
        append(".")
    },
    size = OudsBodyTextSize.Large
)