# ParagraphStyle

Artifact: [androidx.compose.ui:ui-text](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/text/ParagraphStyle.kt+class:androidx.compose.ui.text.ParagraphStyle) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0) Common/AllAndroid/JVM
- Cmn

  ```
  class ParagraphStyle : AnnotatedString.Annotation
  ```

*** ** * ** ***

Paragraph styling configuration.

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

In contrast to `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/SpanStyle` which applies at character level, `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle` separates the marked text into a new paragraph, as if a line feed character was inserted.

```kotlin
import androidx.compose.material3.Text
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextIndent
import androidx.compose.ui.unit.sp

val textStyle =
    TextStyle(
        textAlign = TextAlign.Justify,
        lineHeight = 20.sp,
        textIndent = TextIndent(firstLine = 14.sp, restLine = 3.sp),
    )
Text(
    text =
        "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor " +
            "incididunt ut labore et dolore magna aliqua.\nUt enim ad minim veniam, quis " +
            "nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.",
    style = textStyle,
)
```

```kotlin
import androidx.compose.material3.Text
import androidx.compose.ui.text.ParagraphStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.style.TextIndent
import androidx.compose.ui.unit.sp

val text =
    "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor " +
        "incididunt ut labore et dolore magna aliqua.\nUt enim ad minim veniam, quis " +
        "nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."

val paragraphStyle1 = ParagraphStyle(textIndent = TextIndent(firstLine = 14.sp))
val paragraphStyle2 = ParagraphStyle(lineHeight = 30.sp)

Text(
    text =
        buildAnnotatedString {
            append(text)
            addStyle(paragraphStyle1, 0, text.indexOf('\n') + 1)
            addStyle(paragraphStyle2, text.indexOf('\n') + 1, text.length)
        }
)
```

```kotlin
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.ParagraphStyle
import androidx.compose.ui.unit.sp

with(AnnotatedString.Builder()) {
    // push a ParagraphStyle to be applied to any appended text after this point.
    pushStyle(ParagraphStyle(lineHeight = 18.sp))
    // append a paragraph which will have lineHeight 18.sp
    append("Paragraph One\n")
    // pop the ParagraphStyle
    pop()
    // append new paragraph, this paragraph will not have the line height defined.
    append("Paragraph Two\n")

    toAnnotatedString()
}
```

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/Paragraph` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/AnnotatedString` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/SpanStyle` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/TextStyle` |   |

## Summary

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle#ParagraphStyle(androidx.compose.ui.text.style.TextAlign,androidx.compose.ui.text.style.TextDirection,androidx.compose.ui.unit.TextUnit,androidx.compose.ui.text.style.TextIndent,androidx.compose.ui.text.PlatformParagraphStyle,androidx.compose.ui.text.style.LineHeightStyle,androidx.compose.ui.text.style.LineBreak,androidx.compose.ui.text.style.Hyphens,androidx.compose.ui.text.style.TextMotion)( textAlign: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/style/TextAlign, textDirection: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/style/TextDirection, lineHeight: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit, textIndent: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/style/TextIndent?, platformStyle: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/PlatformParagraphStyle?, lineHeightStyle: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/style/LineHeightStyle?, lineBreak: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/style/LineBreak, hyphens: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/style/Hyphens, textMotion: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/style/TextMotion? )` | Cmn |

| ### Public functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle#copy(androidx.compose.ui.text.style.TextAlign,androidx.compose.ui.text.style.TextDirection,androidx.compose.ui.unit.TextUnit,androidx.compose.ui.text.style.TextIndent,androidx.compose.ui.text.PlatformParagraphStyle,androidx.compose.ui.text.style.LineHeightStyle,androidx.compose.ui.text.style.LineBreak,androidx.compose.ui.text.style.Hyphens,androidx.compose.ui.text.style.TextMotion)( textAlign: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/style/TextAlign, textDirection: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/style/TextDirection, lineHeight: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit, textIndent: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/style/TextIndent?, platformStyle: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/PlatformParagraphStyle?, lineHeightStyle: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/style/LineHeightStyle?, lineBreak: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/style/LineBreak, hyphens: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/style/Hyphens, textMotion: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/style/TextMotion? )` | Cmn |
| `open operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle#equals(kotlin.Any)(other: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle#hashCode()()` | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle#merge(androidx.compose.ui.text.ParagraphStyle)(other: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle?)` Returns a new paragraph style that is a combination of this style and the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle#merge(androidx.compose.ui.text.ParagraphStyle)` style. | Cmn |
| `operator https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle#plus(androidx.compose.ui.text.ParagraphStyle)(other: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle)` Plus operator overload that applies a `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle#merge(androidx.compose.ui.text.ParagraphStyle)`. | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle#toString()()` | Cmn |

| ### Public properties |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/style/Hyphens?` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle#deprecated_boxing_hyphens()` **This property is deprecated.** Kept for backwards compatibility. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/style/LineBreak?` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle#deprecated_boxing_lineBreak()` **This property is deprecated.** Kept for backwards compatibility. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/style/TextAlign?` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle#deprecated_boxing_textAlign()` **This property is deprecated.** Kept for backwards compatibility. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/style/TextDirection?` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle#deprecated_boxing_textDirection()` **This property is deprecated.** Kept for backwards compatibility. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/style/Hyphens` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle#hyphens()` hyphenation configuration. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/style/LineBreak` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle#lineBreak()` line breaking rules. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle#lineHeight()` line height | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/style/LineHeightStyle?` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle#lineHeightStyle()` line height distribution configuration | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/PlatformParagraphStyle?` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle#platformStyle()` platform-specific parameters | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/style/TextAlign` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle#textAlign()` alignment of the text within the lines of the paragraph. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/style/TextDirection` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle#textDirection()` algorithm used to resolve the final text direction: Left To Right or Right To Left. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/style/TextIndent?` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle#textIndent()` paragraph indentation | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/style/TextMotion?` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle#textMotion()` character placement optimization. | Cmn |

## Public constructors

### ParagraphStyle

Cmn Added in [1.9.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.9.0)

```
ParagraphStyle(
    textAlign: TextAlign = TextAlign.Unspecified,
    textDirection: TextDirection = TextDirection.Unspecified,
    lineHeight: TextUnit = TextUnit.Unspecified,
    textIndent: TextIndent? = null,
    platformStyle: PlatformParagraphStyle? = null,
    lineHeightStyle: LineHeightStyle? = null,
    lineBreak: LineBreak = LineBreak.Unspecified,
    hyphens: Hyphens = Hyphens.Unspecified,
    textMotion: TextMotion? = null
)
```

| Parameters |
|---|---|
| `textAlign: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/style/TextAlign = TextAlign.Unspecified` | alignment of the text within the lines of the paragraph. |
| `textDirection: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/style/TextDirection = TextDirection.Unspecified` | algorithm used to resolve the final text direction: Left To Right or Right To Left. |
| `lineHeight: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit = TextUnit.Unspecified` | line height |
| `textIndent: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/style/TextIndent? = null` | paragraph indentation |
| `platformStyle: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/PlatformParagraphStyle? = null` | platform-specific parameters |
| `lineHeightStyle: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/style/LineHeightStyle? = null` | line height distribution configuration |
| `lineBreak: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/style/LineBreak = LineBreak.Unspecified` | line breaking rules. |
| `hyphens: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/style/Hyphens = Hyphens.Unspecified` | hyphenation configuration. |
| `textMotion: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/style/TextMotion? = null` | character placement optimization. |

## Public functions

### copy

Cmn Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

```
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
```

### equals

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
open operator fun equals(other: Any?): Boolean
```

### hashCode

Cmn

```
open fun hashCode(): Int
```

### merge

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun merge(other: ParagraphStyle? = null): ParagraphStyle
```

Returns a new paragraph style that is a combination of this style and the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle#merge(androidx.compose.ui.text.ParagraphStyle)` style.

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

| Parameters |
|---|---|
| `other: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle? = null` | style to merge |

### plus

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
operator fun plus(other: ParagraphStyle): ParagraphStyle
```

Plus operator overload that applies a `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ParagraphStyle#merge(androidx.compose.ui.text.ParagraphStyle)`.

### toString

Cmn

```
open fun toString(): String
```

## Public properties

### deprecated_boxing_hyphens

Cmn Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.7.0) Deprecated in [1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.7.0)

```
val deprecated_boxing_hyphens: Hyphens?
```

> [!CAUTION]
> **This property is deprecated.**   
> Kept for backwards compatibility.

### deprecated_boxing_lineBreak

Cmn Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.7.0) Deprecated in [1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.7.0)

```
val deprecated_boxing_lineBreak: LineBreak?
```

> [!CAUTION]
> **This property is deprecated.**   
> Kept for backwards compatibility.

### deprecated_boxing_textAlign

Cmn Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.7.0) Deprecated in [1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.7.0)

```
val deprecated_boxing_textAlign: TextAlign?
```

> [!CAUTION]
> **This property is deprecated.**   
> Kept for backwards compatibility.

### deprecated_boxing_textDirection

Cmn Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.7.0) Deprecated in [1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.7.0)

```
val deprecated_boxing_textDirection: TextDirection?
```

> [!CAUTION]
> **This property is deprecated.**   
> Kept for backwards compatibility.

### hyphens

Cmn Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.3.0)

```
val hyphens: Hyphens
```

hyphenation configuration.

### lineBreak

Cmn Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.3.0)

```
val lineBreak: LineBreak
```

line breaking rules.

### lineHeight

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
val lineHeight: TextUnit
```

line height

### lineHeightStyle

Cmn Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.2.0)

```
val lineHeightStyle: LineHeightStyle?
```

line height distribution configuration

### platformStyle

Cmn Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.2.0)

```
val platformStyle: PlatformParagraphStyle?
```

platform-specific parameters

### textAlign

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
val textAlign: TextAlign
```

alignment of the text within the lines of the paragraph.

### textDirection

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
val textDirection: TextDirection
```

algorithm used to resolve the final text direction: Left To Right or Right To Left.

### textIndent

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
val textIndent: TextIndent?
```

paragraph indentation

### textMotion

Cmn Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.4.0)

```
val textMotion: TextMotion?
```

character placement optimization.