FadingExpandingLabel

Composable Component

Animates label text for which the number of lines can vary, changing the size of the container component.

Android
@Composable
public fun FadingExpandingLabel(
    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? = LocalTextConfiguration.current.textAlign,
    lineHeight: TextUnit = TextUnit.Unspecified,
    softWrap: Boolean = true,
    maxLines: Int = LocalTextConfiguration.current.maxLines,
    minLines: Int = 1,
    textStyle: TextStyle = LocalTextStyle.current,
    animationSpec: FiniteAnimationSpec<Float> = FadingExpandingLabelDefaults.animationSpec,
)

Parameters

textText string that will be shown.
modifierModifier to be applied to the animated text.
colorColor to apply to the text. If Color.Unspecified, and textStyle has no color set,this will be LocalContentColor.
fontSizeThe size of glyphs to use when painting the text. See TextStyle.fontSize.
fontStyleThe typeface variant to use when drawing the letters (e.g., italic). See TextStyle.fontStyle.
fontWeightThe typeface thickness to use when painting the text (e.g., FontWeight.Bold).
fontFamilyThe font family to be used when rendering the text. See TextStyle.fontFamily.
letterSpacingThe amount of space to add between each letter. See TextStyle.letterSpacing.
textDecorationThe decorations to paint on the text (e.g., an underline). See TextStyle.textDecoration.
textAlignThe alignment of the text within the lines of the paragraph. See TextStyle.textAlign.
lineHeightLine height for the Paragraph in TextUnit unit, e.g. SP or EM. See TextStyle.lineHeight.
softWrapWhether 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, TextAlign may have unexpected effects.
maxLinesAn optional maximum number of lines for the text to span, wrapping if necessary. If it is not null, then it must be greater than zero.
minLinesThe minimum height in terms of minimum number of visible lines. It is required that 1 <= minLines <= maxLines.
textStyleTextStyle for the animated text.
animationSpecAnimation spec for the text fade animation.