OudsHeadingText

fun OudsHeadingText(text: String, modifier: Modifier = Modifier, size: OudsHeadingTextSize = OudsHeadingTextDefaults.Size, color: Color = OudsHeadingTextDefaults.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 = {})

Heading styles are used to structure content and define the hierarchy of information within an interface. Available in multiple sizes, they help users quickly understand the organization of a page or section. Their size automatically adjusts across breakpoints to ensure optimal readability on all devices. Headings serve as the primary entry point for visual navigation.

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

Design

NameHeading
Version1.0.0

Parameters

text

Text to be displayed.

modifier

Modifier applied to the heading text.

size

Size of the heading text.

color

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

OudsHeadingText(
    modifier = Modifier.padding(OudsTheme.spaces.fixed.small),
    text = "Heading",
    size = OudsHeadingTextSize.Medium
)
OudsHeadingText(
    modifier = Modifier.padding(OudsTheme.spaces.fixed.small),
    text = "Heading",
    size = OudsHeadingTextSize.Large()
)
OudsHeadingText(
    modifier = Modifier.padding(OudsTheme.spaces.fixed.small),
    text = "Heading",
    size = OudsHeadingTextSize.Large(marker = false)
)

fun OudsHeadingText(text: AnnotatedString, modifier: Modifier = Modifier, size: OudsHeadingTextSize = OudsHeadingTextDefaults.Size, color: Color = OudsHeadingTextDefaults.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)

Heading styles are used to structure content and define the hierarchy of information within an interface. Available in multiple sizes, they help users quickly understand the organization of a page or section. Their size automatically adjusts across breakpoints to ensure optimal readability on all devices. Headings serve as the primary entry point for visual navigation.

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

Design

NameHeading
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 heading text.

size

Size of the heading text.

color

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

OudsHeadingText(
    modifier = Modifier.padding(OudsTheme.spaces.fixed.small),
    text = buildAnnotatedString {
        append("Heading with ")
        withStyle(SpanStyle(color = OudsTheme.colorScheme.content.brandPrimary)) { append("colored text") }
        append(" and ")
        withStyle(SpanStyle(fontWeight = FontWeight.Normal)) { append("normal text") }
    },
    size = OudsHeadingTextSize.Large(marker = false)
)