Paragraph

Function

Common

Deprecated Font.ResourceLoader is deprecated, instead pass FontFamily.Resolver

fun Paragraph(
    text: String,
    style: TextStyle,
    spanStyles: List<AnnotatedString.Range<SpanStyle>> = listOf(),
    placeholders: List<AnnotatedString.Range<Placeholder>> = listOf(),
    maxLines: Int = DefaultMaxLines,
    ellipsis: Boolean = false,
    width: Float,
    density: Density,
    resourceLoader: Font.ResourceLoader,
): Paragraph

Lays out a given text with the given constraints. A paragraph is a text that has a single ParagraphStyle.

If the style does not contain any androidx.compose.ui.text.style.TextDirection, androidx.compose.ui.text.style.TextDirection.Content is used as the default value.

Parameters

textthe text to be laid out
stylethe TextStyle to be applied to the whole text
spanStylesSpanStyles to be applied to parts of text
placeholdersa list of placeholder metrics which tells Paragraph where should be left blank to leave space for inline elements.
maxLinesthe maximum number of lines that the text can have
ellipsiswhether to ellipsize text, applied only when maxLines is set
widthhow wide the text is allowed to be
densitydensity of the device
resourceLoaderFont.ResourceLoader to be used to load the font given in SpanStyles
Common

Deprecated Paragraph that takes maximum allowed width is deprecated, pass constraints instead.

fun Paragraph(
    text: String,
    style: TextStyle,
    width: Float,
    density: Density,
    fontFamilyResolver: FontFamily.Resolver,
    spanStyles: List<AnnotatedString.Range<SpanStyle>> = listOf(),
    placeholders: List<AnnotatedString.Range<Placeholder>> = listOf(),
    maxLines: Int = DefaultMaxLines,
    ellipsis: Boolean = false,
): Paragraph

Lays out a given text with the given constraints. A paragraph is a text that has a single ParagraphStyle.

If the style does not contain any androidx.compose.ui.text.style.TextDirection, androidx.compose.ui.text.style.TextDirection.Content is used as the default value.

Parameters

textthe text to be laid out
stylethe TextStyle to be applied to the whole text
widthhow wide the text is allowed to be
densitydensity of the device
fontFamilyResolverFontFamily.Resolver to be used to load the font given in SpanStyles
spanStylesSpanStyles to be applied to parts of text
placeholdersa list of placeholder metrics which tells Paragraph where should be left blank to leave space for inline elements.
maxLinesthe maximum number of lines that the text can have
ellipsiswhether to ellipsize text, applied only when maxLines is set
Common

Deprecated Paragraph that takes ellipsis: Boolean is deprecated, pass TextOverflow instead.

fun Paragraph(
    text: String,
    style: TextStyle,
    constraints: Constraints,
    density: Density,
    fontFamilyResolver: FontFamily.Resolver,
    spanStyles: List<AnnotatedString.Range<SpanStyle>> = listOf(),
    placeholders: List<AnnotatedString.Range<Placeholder>> = listOf(),
    maxLines: Int = DefaultMaxLines,
    ellipsis: Boolean = false,
): Paragraph

Lays out a given text with the given constraints. A paragraph is a text that has a single ParagraphStyle.

If the style does not contain any androidx.compose.ui.text.style.TextDirection, androidx.compose.ui.text.style.TextDirection.Content is used as the default value.

Parameters

textthe text to be laid out
stylethe TextStyle to be applied to the whole text
constraintshow wide and tall the text is allowed to be. Constraints.maxWidth will define the width of the Paragraph. Constraints.maxHeight helps defining the number of lines that fit with ellipsis is true. Minimum components of the Constraints object are no-op.
densitydensity of the device
fontFamilyResolverFontFamily.Resolver to be used to load the font given in SpanStyles
spanStylesSpanStyles to be applied to parts of text
placeholdersa list of placeholder metrics which tells Paragraph where should be left blank to leave space for inline elements.
maxLinesthe maximum number of lines that the text can have
ellipsiswhether to ellipsize text, applied only when maxLines is set
Common
fun Paragraph(
    text: String,
    style: TextStyle,
    constraints: Constraints,
    density: Density,
    fontFamilyResolver: FontFamily.Resolver,
    spanStyles: List<AnnotatedString.Range<SpanStyle>> = listOf(),
    placeholders: List<AnnotatedString.Range<Placeholder>> = listOf(),
    maxLines: Int = DefaultMaxLines,
    overflow: TextOverflow = TextOverflow.Clip,
): Paragraph

Lays out a given text with the given constraints. A paragraph is a text that has a single ParagraphStyle.

If the style does not contain any androidx.compose.ui.text.style.TextDirection, androidx.compose.ui.text.style.TextDirection.Content is used as the default value.

Parameters

textthe text to be laid out
stylethe TextStyle to be applied to the whole text
constraintshow wide and tall the text is allowed to be. Constraints.maxWidth will define the width of the Paragraph. Constraints.maxHeight helps defining the number of lines that fit with ellipsis is true. Minimum components of the Constraints object are no-op.
densitydensity of the device
fontFamilyResolverFontFamily.Resolver to be used to load the font given in SpanStyles
spanStylesSpanStyles to be applied to parts of text
placeholdersa list of placeholder metrics which tells Paragraph where should be left blank to leave space for inline elements.
maxLinesthe maximum number of lines that the text can have
overflowspecifies how visual overflow should be handled
Common

Deprecated Paragraph that takes maximum allowed width is deprecated, pass constraints instead.

fun Paragraph(
    paragraphIntrinsics: ParagraphIntrinsics,
    maxLines: Int = DefaultMaxLines,
    ellipsis: Boolean = false,
    width: Float,
): Paragraph

Lays out the text in ParagraphIntrinsics with the given constraints. A paragraph is a text that has a single ParagraphStyle.

Parameters

paragraphIntrinsicsParagraphIntrinsics instance
maxLinesthe maximum number of lines that the text can have
ellipsiswhether to ellipsize text, applied only when maxLines is set
widthhow wide the text is allowed to be
Common

Deprecated Paragraph that takes ellipsis: Boolean is deprecated, pass TextOverflow instead.

fun Paragraph(
    paragraphIntrinsics: ParagraphIntrinsics,
    constraints: Constraints,
    maxLines: Int = DefaultMaxLines,
    ellipsis: Boolean = false,
): Paragraph

Lays out the text in ParagraphIntrinsics with the given constraints. A paragraph is a text that has a single ParagraphStyle.

Parameters

paragraphIntrinsicsParagraphIntrinsics instance
constraintshow wide and tall the text is allowed to be. Constraints.maxWidth will define the width of the Paragraph. Constraints.maxHeight helps defining the number of lines that fit with ellipsis is true. Minimum components of the Constraints object are no-op.
maxLinesthe maximum number of lines that the text can have
ellipsiswhether to ellipsize text, applied only when maxLines is set
Common
fun Paragraph(
    paragraphIntrinsics: ParagraphIntrinsics,
    constraints: Constraints,
    maxLines: Int = DefaultMaxLines,
    overflow: TextOverflow = TextOverflow.Clip,
): Paragraph

Lays out the text in ParagraphIntrinsics with the given constraints. A paragraph is a text that has a single ParagraphStyle.

Parameters

paragraphIntrinsicsParagraphIntrinsics instance
constraintshow wide and tall the text is allowed to be. Constraints.maxWidth will define the width of the Paragraph. Constraints.maxHeight helps defining the number of lines that fit with ellipsis is true. Minimum components of the Constraints object are no-op.
maxLinesthe maximum number of lines that the text can have
overflowspecifies how visual overflow should be handled