OudsLabelText

fun OudsLabelText(text: String, modifier: Modifier = Modifier, size: OudsLabelTextSize = OudsLabelTextDefaults.Size, weight: OudsTextWeight = OudsLabelTextDefaults.Weight, color: Color = OudsLabelTextDefaults.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)

Label styles are intended for compact interface elements such as buttons, form fields, badges, and other small components. Unlike other typography categories, they are not responsive and maintain a fixed size across all breakpoints. This ensures visual consistency and predictable behavior within space-constrained UI elements. Labels should be preferred whenever content is displayed within small components.

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

Design

NameLabel
Version1.0.0

Parameters

text

Text to be displayed.

modifier

Modifier applied to the label text.

size

Size of the label text.

weight

Weight of the label text.

color

Color of the label 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

OudsLabelText(
    modifier = Modifier.padding(OudsTheme.spaces.fixed.small),
    text = "Label",
    size = OudsLabelTextSize.Large,
    weight = OudsTextWeight.Strong
)

fun OudsLabelText(text: AnnotatedString, modifier: Modifier = Modifier, size: OudsLabelTextSize = OudsLabelTextDefaults.Size, weight: OudsTextWeight = OudsLabelTextDefaults.Weight, color: Color = OudsLabelTextDefaults.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 = {})

Label styles are intended for compact interface elements such as buttons, form fields, badges, and other small components. Unlike other typography categories, they are not responsive and maintain a fixed size across all breakpoints. This ensures visual consistency and predictable behavior within space-constrained UI elements. Labels should be preferred whenever content is displayed within small components.

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

Design

NameLabel
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 label text.

size

Size of the label text.

weight

Weight of the label text.

color

Color of the label 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

OudsLabelText(
    modifier = Modifier.padding(OudsTheme.spaces.fixed.small),
    text = buildAnnotatedString {
        append("Label with ")
        withStyle(SpanStyle(color = OudsTheme.colorScheme.content.brandPrimary)) { append("colored text") }
        append(" and ")
        withStyle(SpanStyle(fontWeight = FontWeight.Bold)) { append("bold text") }
    },
    size = OudsLabelTextSize.Large
)