Class

ParagraphStyle

Paragraph styling configuration.

Source set: Common
public class ParagraphStyle internal constructor(
    bits: Long,
    public val lineHeightStyle: LineHeightStyle?,
    /**
     * Rare fields ([textIndent], [platformStyle], [textMotion]) that only make a
     * [ParagraphStyleExtras] object when set to a custom value. Preset values ([TextIndent.None],
     * [PlatformParagraphStyle.Default], [TextMotion.Static], [TextMotion.Animated]) live in [bits],
     * so [extras] stays `null`.
     */
    internal val extras: ParagraphStyleExtras?,
    internal val legacyParagraphStyle: LegacyParagraphStyle?,
) : AnnotatedString.Annotation

Paragraph styling configuration.

Defines styling parameters that apply to a whole paragraph (e.g., alignment, line height).

In contrast to SpanStyle which applies at character level, ParagraphStyle separates the marked text into a new paragraph, as if a line feed character was inserted.

Properties

textAlign

Source set: Common
public val textAlign: TextAlign

Parameters

textAlign alignment of the text within the lines of the paragraph.
textDirection algorithm used to resolve the final text direction: Left To Right or Right To Left.
lineHeight line height
textIndent paragraph indentation
platformStyle platform-specific parameters
lineHeightStyle line height distribution configuration
lineBreak line breaking rules.
hyphens hyphenation configuration.
textMotion character placement optimization.

textDirection

Source set: Common
public val textDirection: TextDirection

lineHeight

Source set: Common
public val lineHeight: TextUnit

textIndent

Source set: Common
public val textIndent: TextIndent?

platformStyle

Source set: Common
public val platformStyle: PlatformParagraphStyle?

lineBreak

Source set: Common
public val lineBreak: LineBreak

hyphens

Source set: Common
public val hyphens: Hyphens

textMotion

Source set: Common
public val textMotion: TextMotion?

deprecatedboxingtextAlign

Source set: Common
@Deprecated("Kept for backwards compatibility.", level = DeprecationLevel.WARNING)
    @get:JvmName("getTextAlign-buA522U") // b/320819734
    public val deprecated_boxing_textAlign: TextAlign?

deprecatedboxingtextDirection

Source set: Common
@Deprecated("Kept for backwards compatibility.", level = DeprecationLevel.WARNING)
    @get:JvmName("getTextDirection-mmuk1to") // b/320819734
    public val deprecated_boxing_textDirection: TextDirection?

deprecatedboxinghyphens

Source set: Common
@Deprecated("Kept for backwards compatibility.", level = DeprecationLevel.WARNING)
    @get:JvmName("getHyphens-EaSxIns") // b/320819734
    public val deprecated_boxing_hyphens: Hyphens?

deprecatedboxinglineBreak

Source set: Common
@Deprecated("Kept for backwards compatibility.", level = DeprecationLevel.WARNING)
    @get:JvmName("getLineBreak-LgCVezo") // b/320819734
    public val deprecated_boxing_lineBreak: LineBreak?

Functions

merge

Source set: Common
public fun merge(other: ParagraphStyle? = null): ParagraphStyle

Returns a new paragraph style that is a combination of this style and the given other style.

If the given paragraph style is null, returns this paragraph style.

Parameters

other style to merge

plus

Source set: Common
@Stable public operator fun plus(other: ParagraphStyle): ParagraphStyle

Plus operator overload that applies a merge.

copy

Source set: Common
@Deprecated(
        "ParagraphStyle copy constructors that do not take new stable parameters " +
            "like LineHeightStyle, LineBreak, Hyphens are deprecated. Please use the new stable " +
            "copy constructor.",
        level = DeprecationLevel.HIDDEN,
    )
    public fun copy(
        textAlign: TextAlign? = this.textAlign,
        textDirection: TextDirection? = this.textDirection,
        lineHeight: TextUnit = this.lineHeight,
        textIndent: TextIndent? = this.textIndent,
    ): ParagraphStyle

copy

Source set: Common
@Deprecated(
        "ParagraphStyle copy constructors that do not take new stable parameters " +
            "like LineHeightStyle, LineBreak, Hyphens are deprecated. Please use the new stable " +
            "copy constructor.",
        level = DeprecationLevel.HIDDEN,
    )
    public fun copy(
        textAlign: TextAlign? = this.textAlign,
        textDirection: TextDirection? = this.textDirection,
        lineHeight: TextUnit = this.lineHeight,
        textIndent: TextIndent? = this.textIndent,
        platformStyle: PlatformParagraphStyle? = this.platformStyle,
        lineHeightStyle: LineHeightStyle? = this.lineHeightStyle,
    ): ParagraphStyle

copy

Source set: Common
@Deprecated(
        "ParagraphStyle copy constructors that do not take new stable parameters " +
            "like LineBreak, Hyphens, TextMotion are deprecated. Please use the new stable " +
            "copy constructor.",
        level = DeprecationLevel.HIDDEN,
    )
    public fun copy(
        textAlign: TextAlign? = this.textAlign,
        textDirection: TextDirection? = this.textDirection,
        lineHeight: TextUnit = this.lineHeight,
        textIndent: TextIndent? = this.textIndent,
        platformStyle: PlatformParagraphStyle? = this.platformStyle,
        lineHeightStyle: LineHeightStyle? = this.lineHeightStyle,
        lineBreak: LineBreak? = this.lineBreak,
        hyphens: Hyphens? = this.hyphens,
    ): ParagraphStyle

copy

Source set: Common
@Deprecated(
        "ParagraphStyle copy constructors that take nullable TextAlign, " +
            "TextDirection, LineBreak, and Hyphens are deprecated. Please use a new constructor " +
            "where these parameters are non-nullable. Null value has been replaced by a special " +
            "Unspecified object for performance reason.",
        level = DeprecationLevel.HIDDEN,
    )
    public fun copy(
        textAlign: TextAlign? = this.textAlign,
        textDirection: TextDirection? = this.textDirection,
        lineHeight: TextUnit = this.lineHeight,
        textIndent: TextIndent? = this.textIndent,
        platformStyle: PlatformParagraphStyle? = this.platformStyle,
        lineHeightStyle: LineHeightStyle? = this.lineHeightStyle,
        lineBreak: LineBreak? = this.lineBreak,
        hyphens: Hyphens? = this.hyphens,
        textMotion: TextMotion? = this.textMotion,
    ): ParagraphStyle

copy

Source set: Common
public fun copy(
        textAlign: TextAlign = this.textAlign,
        textDirection: TextDirection = this.textDirection,
        lineHeight: TextUnit = this.lineHeight,
        textIndent: TextIndent? = this.textIndent,
        platformStyle: PlatformParagraphStyle? = this.platformStyle,
        lineHeightStyle: LineHeightStyle? = this.lineHeightStyle,
        lineBreak: LineBreak = this.lineBreak,
        hyphens: Hyphens = this.hyphens,
        textMotion: TextMotion? = this.textMotion,
    ): ParagraphStyle
Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: