---
title: "LineBreak"
description: "When soft wrap is enabled and the width of the text exceeds the width of its container, line
breaks are inserted in the text to split it over multiple lines.

There are a number of parameters that affect how the line breaks are inserted. For example, the
breaking algorithm can be changed to one with improved readability at the cost of speed. Another
example is the strictness, which in some languages determines which symbols can appear at the
start of a line.

`LineBreak` represents a configuration for line breaking, offering several presets for different
use cases: [Simple], [Heading], [Paragraph].


For further customization, each platform has its own parameters. An example on Android:"
type: "class"
---

<div class='type'>Class</div>


<a id='references'></a>

<div class='sourceset sourceset-common'>Common</div>


```kotlin
expect value class LineBreak
@Suppress("KmpVisibilityMismatch")
private constructor(internal val mask: Int)
```


When soft wrap is enabled and the width of the text exceeds the width of its container, line
breaks are inserted in the text to split it over multiple lines.

There are a number of parameters that affect how the line breaks are inserted. For example, the
breaking algorithm can be changed to one with improved readability at the cost of speed. Another
example is the strictness, which in some languages determines which symbols can appear at the
start of a line.

`LineBreak` represents a configuration for line breaking, offering several presets for different
use cases: `Simple`, `Heading`, `Paragraph`.


For further customization, each platform has its own parameters. An example on Android:


## Companion Object

#### Properties

<div class='sourceset sourceset-common'>Common</div>


```kotlin
val Simple: LineBreak
```


Basic, fast line breaking. Ideal for text input fields, as it will cause minimal text
reflow when editing.



<div class='sourceset sourceset-common'>Common</div>


```kotlin
val Heading: LineBreak
```


Looser breaking rules, suitable for short text such as titles or narrow newspaper
columns. For longer lines of text, use `Paragraph` for improved readability.



<div class='sourceset sourceset-common'>Common</div>


```kotlin
val Paragraph: LineBreak
```


Slower, higher quality line breaking for improved readability. Suitable for larger
amounts of text.



<div class='sourceset sourceset-common'>Common</div>


```kotlin
val Unspecified: LineBreak
```


This represents an unset value, a usual replacement for "null" when a primitive value is
desired.




<div class='sourceset sourceset-android'>Android</div>


```kotlin
actual value class LineBreak internal constructor(internal val mask: Int)
```


When soft wrap is enabled and the width of the text exceeds the width of its container, line
breaks are inserted in the text to split it over multiple lines.

There are a number of parameters that affect how the line breaks are inserted. For example, the
breaking algorithm can be changed to one with improved readability at the cost of speed. Another
example is the strictness, which in some languages determines which symbols can appear at the
start of a line.

This represents a configuration for line breaking on Android, describing `Strategy`,
`Strictness`, and `WordBreak`.


## Secondary Constructors

```kotlin
constructor(
    strategy: Strategy,
    strictness: Strictness,
    wordBreak: WordBreak,
) : this(packBytes(strategy.value, strictness.value, wordBreak.value))
```


This represents a configuration for line breaking on Android, describing `Strategy`,
`Strictness`, and `WordBreak`.

#### Parameters

| | |
| --- | --- |
| strategy | defines the algorithm that inserts line breaks |
| strictness | defines the line breaking rules |
| wordBreak | defines how words are broken |



## Properties

<div class='sourceset sourceset-android'>Android</div>


```kotlin
val strategy: Strategy
```


<div class='sourceset sourceset-android'>Android</div>


```kotlin
val strictness: Strictness
```


<div class='sourceset sourceset-android'>Android</div>


```kotlin
val wordBreak: WordBreak
```


## Functions

```kotlin
fun copy(
        strategy: Strategy = this.strategy,
        strictness: Strictness = this.strictness,
        wordBreak: WordBreak = this.wordBreak,
    ): LineBreak
```

## Companion Object

#### Properties

<div class='sourceset sourceset-android'>Android</div>


```kotlin
actual val Simple: LineBreak
```


The greedy, fast line breaking algorithm. Ideal for text that updates often, such as a
text editor, as the text will reflow minimally.
<pre>
+---------+
| This is |
| an      |
| example |
| text.   |
| 今日は自  |
| 由が丘で  |
| 焼き鳥を  |
| 食べま   |
| す。     |
+---------+
</pre>



<div class='sourceset sourceset-android'>Android</div>


```kotlin
actual val Heading: LineBreak
```


Balanced line lengths, hyphenation, and phrase-based breaking. Suitable for short text
such as titles or narrow newspaper columns.
<pre>
+---------+
| This    |
| is an   |
| example |
| text.   |
| 今日は   |
| 自由が丘  |
| で焼き鳥  |
| を食べ   |
| ます。   |
+---------+
</pre>



<div class='sourceset sourceset-android'>Android</div>


```kotlin
actual val Paragraph: LineBreak
```


Slower, higher quality line breaking for improved readability. Suitable for larger
amounts of text.
<pre>
+---------+
| This    |
| is an   |
| example |
| text.   |
| 今日は自  |
| 由が丘で  |
| 焼き鳥を  |
| 食べま   |
| す。     |
+---------+
</pre>



<div class='sourceset sourceset-android'>Android</div>


```kotlin
actual val Unspecified: LineBreak
```


This represents an unset value, a usual replacement for "null" when a primitive value is
desired.





## Code Examples

### AndroidLineBreakSample
```kotlin
@Composable
fun AndroidLineBreakSample() {
    val customTitleLineBreak =
        LineBreak(
            strategy = LineBreak.Strategy.Simple,
            strictness = LineBreak.Strictness.Loose,
            wordBreak = LineBreak.WordBreak.Default,
        )
    Text(
        text = "Title of an article",
        style = TextStyle(fontSize = 20.sp, lineBreak = customTitleLineBreak),
    )
    val defaultStrictnessParagraphLineBreak =
        LineBreak.Paragraph.copy(strictness = LineBreak.Strictness.Default)
    Text(
        text = "A long paragraph in an article",
        style = TextStyle(lineBreak = defaultStrictnessParagraphLineBreak),
    )
}
```

### LineBreakSample
```kotlin
@Composable
fun LineBreakSample() {
    Text(
        text = "Title of an article",
        style = TextStyle(fontSize = 20.sp, lineBreak = LineBreak.Heading),
    )
    Text(
        text = "A long paragraph in an article",
        style = TextStyle(lineBreak = LineBreak.Paragraph),
    )
}
```

