🌈 Create new beautiful Compose Gradients with our new wesite ->
Class

LineBreak

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.

Source set: Android
public actual 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.

Properties

strategy

Source set: Android
public val strategy: Strategy

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

strictness

Source set: Android
public val strictness: Strictness

wordBreak

Source set: Android
public val wordBreak: WordBreak

Functions

copy

Source set: Android
public fun copy(
        strategy: Strategy = this.strategy,
        strictness: Strictness = this.strictness,
        wordBreak: WordBreak = this.wordBreak,
    ): LineBreak

Members

Companion

Source set: Android
public actual companion object

Properties

Simple

Source set: Android
public val Simple: LineBreak =
            LineBreak(
                packBytes(Strategy.Simple.value, Strictness.Normal.value, WordBreak.Default.value)
            )

The greedy, fast line breaking algorithm. Ideal for text that updates often, such as a text editor, as the text will reflow minimally.

+---------+ | This is | | an | | example | | text. | | 今ζ—₯はθ‡ͺ | | η”±γŒδΈ˜γ§ | | 焼きι³₯γ‚’ | | 食べま | | す。 | +---------+

Heading

Source set: Android
public val Heading: LineBreak =
            LineBreak(
                packBytes(Strategy.Balanced.value, Strictness.Loose.value, WordBreak.Phrase.value)
            )

Balanced line lengths, hyphenation, and phrase-based breaking. Suitable for short text such as titles or narrow newspaper columns.

+---------+ | This | | is an | | example | | text. | | 今ζ—₯は | | θ‡ͺη”±γŒδΈ˜ | | で焼きι³₯ | | γ‚’ι£ŸγΉ | | ます。 | +---------+

Paragraph

Source set: Android
public val Paragraph: LineBreak =
            LineBreak(
                packBytes(
                    Strategy.HighQuality.value,
                    Strictness.Strict.value,
                    WordBreak.Default.value,
                )
            )

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

+---------+ | This | | is an | | example | | text. | | 今ζ—₯はθ‡ͺ | | η”±γŒδΈ˜γ§ | | 焼きι³₯γ‚’ | | 食べま | | す。 | +---------+

Unspecified

Source set: Android
public val Unspecified: LineBreak

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

Strategy

Source set: Android
public class Strategy internal constructor(internal val value: Int)

The strategy used for line breaking.

Members

Companion

Source set: Android
public companion object

Properties

Simple

Source set: Android
public val Simple: Strategy

Basic, fast break strategy. Hyphenation, if enabled, is done only for words that don't fit on an entire line by themselves.

+---------+ | This is | | an | | example | | text. | +---------+

HighQuality

Source set: Android
public val HighQuality: Strategy

Does whole paragraph optimization for more readable text, including hyphenation if enabled.

+---------+ | This | | is an | | example | | text. | +---------+

Balanced

Source set: Android
public val Balanced: Strategy

Attempts to balance the line lengths of the text, also applying automatic hyphenation if enabled. Suitable for small screens.

+-----------------------+ | This is an | | example text. | +-----------------------+

Unspecified

Source set: Android
public val Unspecified: Strategy

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

Strictness

Source set: Android
public class Strictness internal constructor(internal val value: Int)

Describes the strictness of line breaking, determining before which characters line breaks can be inserted. It is useful when working with CJK scripts.

Members

Companion

Source set: Android
public companion object

Properties

Default

Source set: Android
public val Default: Strictness

Default breaking rules for the locale, which may correspond to Normal or Strict.

Loose

Source set: Android
public val Loose: Strictness

The least restrictive rules, suitable for short lines.

For example, in Japanese it allows breaking before iteration marks, such as γ€…, γ€».

Normal

Source set: Android
public val Normal: Strictness

The most common rules for line breaking.

For example, in Japanese it allows breaking before characters like small hiragana (ぁ), small katakana (γ‚‘), halfwidth variants (ο½§).

Strict

Source set: Android
public val Strict: Strictness

The most stringent rules for line breaking.

For example, in Japanese it does not allow breaking before characters like small hiragana (ぁ), small katakana (γ‚‘), halfwidth variants (ο½§).

Unspecified

Source set: Android
public val Unspecified: Strictness

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

WordBreak

Source set: Android
public class WordBreak internal constructor(internal val value: Int)

Describes how line breaks should be inserted within words.

Functions

toString

Source set: Android
override fun toString(): String

Members

Companion

Source set: Android
public companion object

Properties

Default

Source set: Android
public val Default: WordBreak

Default word breaking rules for the locale. In latin scripts this means inserting line breaks between words, while in languages that don't use whitespace (e.g. Japanese) the line can break between characters.

+---------+ | This is | | an | | example | | text. | | 今ζ—₯はθ‡ͺ | | η”±γŒδΈ˜γ§ | | 焼きι³₯γ‚’ | | 食べま | | す。 | +---------+

Phrase

Source set: Android
public val Phrase: WordBreak

Line breaking is based on phrases. In languages that don't use whitespace (e.g. Japanese), line breaks are not inserted between characters that are part of the same phrase unit. This is ideal for short text such as titles and UI labels.

+---------+ | This | | is an | | example | | text. | | 今ζ—₯は | | θ‡ͺη”±γŒδΈ˜ | | で焼きι³₯ | | γ‚’ι£ŸγΉ | | ます。 | +---------+

Unspecified

Source set: Android
public val Unspecified: WordBreak

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

Source set: Common
public expect class LineBreak private constructor(internal val mask: Int)

Configures line breaking behavior when text wraps automatically to fit its container.

Offers presets for common use cases:

Preset Use Case
Simple Text fields and inputs
Heading Titles and short text
Paragraph Body text and long passages

Customize Android behavior using:

    paragraph-optimized breaking).

  • Strategy: Balances layout speed against formatting quality (e.g., greedy vs.
  • Korean), determining which characters can start or end a line.

  • Strictness: Adjusts line-breaking rules for East Asian languages (Chinese, Japanese, and
  • phrase-based breaking (ideal for titles).

  • WordBreak: Specifies word boundary rules, such as default spacing-based breaking or

Members

Companion

Source set: Common
public companion object

Properties

Simple

Source set: Common
@Stable public val Simple: LineBreak

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

Heading

Source set: Common
@Stable public 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.

Paragraph

Source set: Common
@Stable public val Paragraph: LineBreak

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

Unspecified

Source set: Common
@Stable public val Unspecified: LineBreak

Represents an unset LineBreak value.