---
title: "TextStyle"
description: "Styling configuration for a `Text`."
type: "class"
---

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


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

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


```kotlin
class TextStyle
internal constructor(
    internal val spanStyle: SpanStyle,
    internal val paragraphStyle: ParagraphStyle,
    val platformStyle: PlatformTextStyle? = null,
)
```


Styling configuration for a `Text`.

#### Parameters

| | |
| --- | --- |
| platformStyle | Platform specific `TextStyle` parameters. |



## Secondary Constructors

```kotlin
internal constructor(
    spanStyle: SpanStyle,
    paragraphStyle: ParagraphStyle,
) : this(
    spanStyle = spanStyle,
    paragraphStyle = paragraphStyle,
    platformStyle =
        createPlatformTextStyleInternal(spanStyle.platformStyle, paragraphStyle.platformStyle),
)
```

```kotlin
constructor(
    color: Color = Color.Unspecified,
    fontSize: TextUnit = TextUnit.Unspecified,
    fontWeight: FontWeight? = null,
    fontStyle: FontStyle? = null,
    fontSynthesis: FontSynthesis? = null,
    fontFamily: FontFamily? = null,
    fontFeatureSettings: String? = null,
    letterSpacing: TextUnit = TextUnit.Unspecified,
    baselineShift: BaselineShift? = null,
    textGeometricTransform: TextGeometricTransform? = null,
    localeList: LocaleList? = null,
    background: Color = Color.Unspecified,
    textDecoration: TextDecoration? = null,
    shadow: Shadow? = null,
    textAlign: TextAlign? = null,
    textDirection: TextDirection? = null,
    lineHeight: TextUnit = TextUnit.Unspecified,
    textIndent: TextIndent? = null,
) : this(
    SpanStyle(
        color = color,
        fontSize = fontSize,
        fontWeight = fontWeight,
        fontStyle = fontStyle,
        fontSynthesis = fontSynthesis,
        fontFamily = fontFamily,
        fontFeatureSettings = fontFeatureSettings,
        letterSpacing = letterSpacing,
        baselineShift = baselineShift,
        textGeometricTransform = textGeometricTransform,
        localeList = localeList,
        background = background,
        textDecoration = textDecoration,
        shadow = shadow,
        platformStyle = null,
        drawStyle = null,
    ),
    ParagraphStyle(
        textAlign = textAlign ?: TextAlign.Unspecified,
        textDirection = textDirection ?: TextDirection.Unspecified,
        lineHeight = lineHeight,
        textIndent = textIndent,
        platformStyle = null,
        lineHeightStyle = null,
        lineBreak = LineBreak.Unspecified,
        hyphens = Hyphens.Unspecified,
        textMotion = null,
    ),
    platformStyle = null,
)
```

```kotlin
constructor(
    color: Color = Color.Unspecified,
    fontSize: TextUnit = TextUnit.Unspecified,
    fontWeight: FontWeight? = null,
    fontStyle: FontStyle? = null,
    fontSynthesis: FontSynthesis? = null,
    fontFamily: FontFamily? = null,
    fontFeatureSettings: String? = null,
    letterSpacing: TextUnit = TextUnit.Unspecified,
    baselineShift: BaselineShift? = null,
    textGeometricTransform: TextGeometricTransform? = null,
    localeList: LocaleList? = null,
    background: Color = Color.Unspecified,
    textDecoration: TextDecoration? = null,
    shadow: Shadow? = null,
    textAlign: TextAlign? = null,
    textDirection: TextDirection? = null,
    lineHeight: TextUnit = TextUnit.Unspecified,
    textIndent: TextIndent? = null,
    platformStyle: PlatformTextStyle? = null,
    lineHeightStyle: LineHeightStyle? = null,
) : this(
    SpanStyle(
        color = color,
        fontSize = fontSize,
        fontWeight = fontWeight,
        fontStyle = fontStyle,
        fontSynthesis = fontSynthesis,
        fontFamily = fontFamily,
        fontFeatureSettings = fontFeatureSettings,
        letterSpacing = letterSpacing,
        baselineShift = baselineShift,
        textGeometricTransform = textGeometricTransform,
        localeList = localeList,
        background = background,
        textDecoration = textDecoration,
        shadow = shadow,
        platformStyle = platformStyle?.spanStyle,
        drawStyle = null,
    ),
    ParagraphStyle(
        textAlign = textAlign ?: TextAlign.Unspecified,
        textDirection = textDirection ?: TextDirection.Unspecified,
        lineHeight = lineHeight,
        textIndent = textIndent,
        platformStyle = platformStyle?.paragraphStyle,
        lineHeightStyle = lineHeightStyle,
        lineBreak = LineBreak.Unspecified,
        hyphens = Hyphens.Unspecified,
        textMotion = null,
    ),
    platformStyle = platformStyle,
)
```

```kotlin
constructor(
    color: Color = Color.Unspecified,
    fontSize: TextUnit = TextUnit.Unspecified,
    fontWeight: FontWeight? = null,
    fontStyle: FontStyle? = null,
    fontSynthesis: FontSynthesis? = null,
    fontFamily: FontFamily? = null,
    fontFeatureSettings: String? = null,
    letterSpacing: TextUnit = TextUnit.Unspecified,
    baselineShift: BaselineShift? = null,
    textGeometricTransform: TextGeometricTransform? = null,
    localeList: LocaleList? = null,
    background: Color = Color.Unspecified,
    textDecoration: TextDecoration? = null,
    shadow: Shadow? = null,
    textAlign: TextAlign? = null,
    textDirection: TextDirection? = null,
    lineHeight: TextUnit = TextUnit.Unspecified,
    textIndent: TextIndent? = null,
    platformStyle: PlatformTextStyle? = null,
    lineHeightStyle: LineHeightStyle? = null,
    lineBreak: LineBreak? = null,
    hyphens: Hyphens? = null,
) : this(
    SpanStyle(
        color = color,
        fontSize = fontSize,
        fontWeight = fontWeight,
        fontStyle = fontStyle,
        fontSynthesis = fontSynthesis,
        fontFamily = fontFamily,
        fontFeatureSettings = fontFeatureSettings,
        letterSpacing = letterSpacing,
        baselineShift = baselineShift,
        textGeometricTransform = textGeometricTransform,
        localeList = localeList,
        background = background,
        textDecoration = textDecoration,
        shadow = shadow,
        platformStyle = platformStyle?.spanStyle,
    ),
    ParagraphStyle(
        textAlign = textAlign ?: TextAlign.Unspecified,
        textDirection = textDirection ?: TextDirection.Unspecified,
        lineHeight = lineHeight,
        textIndent = textIndent,
        platformStyle = platformStyle?.paragraphStyle,
        lineHeightStyle = lineHeightStyle,
        lineBreak = lineBreak ?: LineBreak.Unspecified,
        hyphens = hyphens ?: Hyphens.Unspecified,
    ),
    platformStyle = platformStyle,
)
```


Styling configuration for a `Text`.

#### Parameters

| | |
| --- | --- |
| color | The text color. |
| fontSize | The size of glyphs to use when painting the text. This may be `TextUnit.Unspecified` for inheriting from another `TextStyle`. |
| fontWeight | The typeface thickness to use when painting the text (e.g., bold). |
| fontStyle | The typeface variant to use when drawing the letters (e.g., italic). |
| fontSynthesis | Whether to synthesize font weight and/or style when the requested weight or style cannot be found in the provided font family. |
| fontFamily | The font family to be used when rendering the text. |
| fontFeatureSettings | The advanced typography settings provided by font. The format is the same as the CSS font-feature-settings attribute: https://www.w3.org/TR/css-fonts-3/#font-feature-settings-prop |
| letterSpacing | The amount of space to add between each letter. |
| baselineShift | The amount by which the text is shifted up from the current baseline. |
| textGeometricTransform | The geometric transformation applied the text. |
| localeList | The locale list used to select region-specific glyphs. |
| background | The background color for the text. |
| textDecoration | The decorations to paint on the text (e.g., an underline). |
| shadow | The shadow effect applied on the text. |
| textAlign | The alignment of the text within the lines of the paragraph. |
| textDirection | The algorithm to be used to resolve the final text and paragraph direction: Left To Right or Right To Left. If no value is provided the system will use the `LayoutDirection` as the primary signal. |
| lineHeight | Line height for the `Paragraph` in `TextUnit` unit, e.g. SP or EM. |
| textIndent | The indentation of the paragraph. |
| platformStyle | Platform specific `TextStyle` parameters. |
| lineHeightStyle | the configuration for line height such as vertical alignment of the line, whether to apply additional space as a result of line height to top of first line top and bottom of last line. The configuration is applied only when a `lineHeight` is defined. When null, `LineHeightStyle.Default` is used. |
| lineBreak | The line breaking configuration for the text. |
| hyphens | The configuration of hyphenation. |



```kotlin
constructor(
    color: Color = Color.Unspecified,
    fontSize: TextUnit = TextUnit.Unspecified,
    fontWeight: FontWeight? = null,
    fontStyle: FontStyle? = null,
    fontSynthesis: FontSynthesis? = null,
    fontFamily: FontFamily? = null,
    fontFeatureSettings: String? = null,
    letterSpacing: TextUnit = TextUnit.Unspecified,
    baselineShift: BaselineShift? = null,
    textGeometricTransform: TextGeometricTransform? = null,
    localeList: LocaleList? = null,
    background: Color = Color.Unspecified,
    textDecoration: TextDecoration? = null,
    shadow: Shadow? = null,
    drawStyle: DrawStyle? = null,
    textAlign: TextAlign? = null,
    textDirection: TextDirection? = null,
    lineHeight: TextUnit = TextUnit.Unspecified,
    textIndent: TextIndent? = null,
    platformStyle: PlatformTextStyle? = null,
    lineHeightStyle: LineHeightStyle? = null,
    lineBreak: LineBreak? = null,
    hyphens: Hyphens? = null,
    textMotion: TextMotion? = null,
) : this(
    SpanStyle(
        color = color,
        fontSize = fontSize,
        fontWeight = fontWeight,
        fontStyle = fontStyle,
        fontSynthesis = fontSynthesis,
        fontFamily = fontFamily,
        fontFeatureSettings = fontFeatureSettings,
        letterSpacing = letterSpacing,
        baselineShift = baselineShift,
        textGeometricTransform = textGeometricTransform,
        localeList = localeList,
        background = background,
        textDecoration = textDecoration,
        shadow = shadow,
        platformStyle = platformStyle?.spanStyle,
        drawStyle = drawStyle,
    ),
    ParagraphStyle(
        textAlign = textAlign ?: TextAlign.Unspecified,
        textDirection = textDirection ?: TextDirection.Unspecified,
        lineHeight = lineHeight,
        textIndent = textIndent,
        platformStyle = platformStyle?.paragraphStyle,
        lineHeightStyle = lineHeightStyle,
        lineBreak = lineBreak ?: LineBreak.Unspecified,
        hyphens = hyphens ?: Hyphens.Unspecified,
        textMotion = textMotion,
    ),
    platformStyle = platformStyle,
)
```

```kotlin
constructor(
    color: Color = Color.Unspecified,
    fontSize: TextUnit = TextUnit.Unspecified,
    fontWeight: FontWeight? = null,
    fontStyle: FontStyle? = null,
    fontSynthesis: FontSynthesis? = null,
    fontFamily: FontFamily? = null,
    fontFeatureSettings: String? = null,
    letterSpacing: TextUnit = TextUnit.Unspecified,
    baselineShift: BaselineShift? = null,
    textGeometricTransform: TextGeometricTransform? = null,
    localeList: LocaleList? = null,
    background: Color = Color.Unspecified,
    textDecoration: TextDecoration? = null,
    shadow: Shadow? = null,
    drawStyle: DrawStyle? = null,
    textAlign: TextAlign = TextAlign.Unspecified,
    textDirection: TextDirection = TextDirection.Unspecified,
    lineHeight: TextUnit = TextUnit.Unspecified,
    textIndent: TextIndent? = null,
    platformStyle: PlatformTextStyle? = null,
    lineHeightStyle: LineHeightStyle? = null,
    lineBreak: LineBreak = LineBreak.Unspecified,
    hyphens: Hyphens = Hyphens.Unspecified,
    textMotion: TextMotion? = null,
) : this(
    SpanStyle(
        color = color,
        fontSize = fontSize,
        fontWeight = fontWeight,
        fontStyle = fontStyle,
        fontSynthesis = fontSynthesis,
        fontFamily = fontFamily,
        fontFeatureSettings = fontFeatureSettings,
        letterSpacing = letterSpacing,
        baselineShift = baselineShift,
        textGeometricTransform = textGeometricTransform,
        localeList = localeList,
        background = background,
        textDecoration = textDecoration,
        shadow = shadow,
        platformStyle = platformStyle?.spanStyle,
        drawStyle = drawStyle,
    ),
    ParagraphStyle(
        textAlign = textAlign,
        textDirection = textDirection,
        lineHeight = lineHeight,
        textIndent = textIndent,
        platformStyle = platformStyle?.paragraphStyle,
        lineHeightStyle = lineHeightStyle,
        lineBreak = lineBreak,
        hyphens = hyphens,
        textMotion = textMotion,
    ),
    platformStyle = platformStyle,
)
```


Styling configuration for a `Text`.

#### Parameters

| | |
| --- | --- |
| color | The text color. |
| fontSize | The size of glyphs to use when painting the text. This may be `TextUnit.Unspecified` for inheriting from another `TextStyle`. |
| fontWeight | The typeface thickness to use when painting the text (e.g., bold). |
| fontStyle | The typeface variant to use when drawing the letters (e.g., italic). |
| fontSynthesis | Whether to synthesize font weight and/or style when the requested weight or style cannot be found in the provided font family. |
| fontFamily | The font family to be used when rendering the text. |
| fontFeatureSettings | The advanced typography settings provided by font. The format is the same as the CSS font-feature-settings attribute: https://www.w3.org/TR/css-fonts-3/#font-feature-settings-prop |
| letterSpacing | The amount of space to add between each letter. |
| baselineShift | The amount by which the text is shifted up from the current baseline. |
| textGeometricTransform | The geometric transformation applied the text. |
| localeList | The locale list used to select region-specific glyphs. |
| background | The background color for the text. |
| textDecoration | The decorations to paint on the text (e.g., an underline). |
| shadow | The shadow effect applied on the text. |
| drawStyle | Drawing style of text, whether fill in the text while drawing or stroke around the edges. |
| textAlign | The alignment of the text within the lines of the paragraph. |
| textDirection | The algorithm to be used to resolve the final text and paragraph direction: Left To Right or Right To Left. If no value is provided the system will use the `LayoutDirection` as the primary signal. |
| lineHeight | Line height for the `Paragraph` in `TextUnit` unit, e.g. SP or EM. |
| textIndent | The indentation of the paragraph. |
| platformStyle | Platform specific `TextStyle` parameters. |
| lineHeightStyle | the configuration for line height such as vertical alignment of the line, whether to apply additional space as a result of line height to top of first line top and bottom of last line. The configuration is applied only when a `lineHeight` is defined. When null, `LineHeightStyle.Default` is used. |
| lineBreak | The line breaking configuration for the text. |
| hyphens | The configuration of hyphenation. |
| textMotion | Text character placement, whether to optimize for animated or static text. |



```kotlin
constructor(
    brush: Brush?,
    alpha: Float = Float.NaN,
    fontSize: TextUnit = TextUnit.Unspecified,
    fontWeight: FontWeight? = null,
    fontStyle: FontStyle? = null,
    fontSynthesis: FontSynthesis? = null,
    fontFamily: FontFamily? = null,
    fontFeatureSettings: String? = null,
    letterSpacing: TextUnit = TextUnit.Unspecified,
    baselineShift: BaselineShift? = null,
    textGeometricTransform: TextGeometricTransform? = null,
    localeList: LocaleList? = null,
    background: Color = Color.Unspecified,
    textDecoration: TextDecoration? = null,
    shadow: Shadow? = null,
    drawStyle: DrawStyle? = null,
    textAlign: TextAlign = TextAlign.Unspecified,
    textDirection: TextDirection = TextDirection.Unspecified,
    lineHeight: TextUnit = TextUnit.Unspecified,
    textIndent: TextIndent? = null,
    platformStyle: PlatformTextStyle? = null,
    lineHeightStyle: LineHeightStyle? = null,
    lineBreak: LineBreak = LineBreak.Unspecified,
    hyphens: Hyphens = Hyphens.Unspecified,
    textMotion: TextMotion? = null,
) : this(
    SpanStyle(
        brush = brush,
        alpha = alpha,
        fontSize = fontSize,
        fontWeight = fontWeight,
        fontStyle = fontStyle,
        fontSynthesis = fontSynthesis,
        fontFamily = fontFamily,
        fontFeatureSettings = fontFeatureSettings,
        letterSpacing = letterSpacing,
        baselineShift = baselineShift,
        textGeometricTransform = textGeometricTransform,
        localeList = localeList,
        background = background,
        textDecoration = textDecoration,
        shadow = shadow,
        platformStyle = platformStyle?.spanStyle,
        drawStyle = drawStyle,
    ),
    ParagraphStyle(
        textAlign = textAlign,
        textDirection = textDirection,
        lineHeight = lineHeight,
        textIndent = textIndent,
        platformStyle = platformStyle?.paragraphStyle,
        lineHeightStyle = lineHeightStyle,
        lineBreak = lineBreak,
        hyphens = hyphens,
        textMotion = textMotion,
    ),
    platformStyle = platformStyle,
)
```


Styling configuration for a `Text`.

#### Parameters

| | |
| --- | --- |
| brush | The brush to use when painting the text. If brush is given as null, it will be treated as unspecified. It is equivalent to calling the alternative color constructor with `Color.Unspecified` |
| alpha | Opacity to be applied to `brush` from 0.0f to 1.0f representing fully transparent to fully opaque respectively. |
| fontSize | The size of glyphs to use when painting the text. This may be `TextUnit.Unspecified` for inheriting from another `TextStyle`. |
| fontWeight | The typeface thickness to use when painting the text (e.g., bold). |
| fontStyle | The typeface variant to use when drawing the letters (e.g., italic). |
| fontSynthesis | Whether to synthesize font weight and/or style when the requested weight or style cannot be found in the provided font family. |
| fontFamily | The font family to be used when rendering the text. |
| fontFeatureSettings | The advanced typography settings provided by font. The format is the same as the CSS font-feature-settings attribute: https://www.w3.org/TR/css-fonts-3/#font-feature-settings-prop |
| letterSpacing | The amount of space to add between each letter. |
| baselineShift | The amount by which the text is shifted up from the current baseline. |
| textGeometricTransform | The geometric transformation applied the text. |
| localeList | The locale list used to select region-specific glyphs. |
| background | The background color for the text. |
| textDecoration | The decorations to paint on the text (e.g., an underline). |
| shadow | The shadow effect applied on the text. |
| drawStyle | Drawing style of text, whether fill in the text while drawing or stroke around the edges. |
| textAlign | The alignment of the text within the lines of the paragraph. |
| textDirection | The algorithm to be used to resolve the final text and paragraph direction: Left To Right or Right To Left. If no value is provided the system will use the `LayoutDirection` as the primary signal. |
| lineHeight | Line height for the `Paragraph` in `TextUnit` unit, e.g. SP or EM. |
| textIndent | The indentation of the paragraph. |
| platformStyle | Platform specific `TextStyle` parameters. |
| lineHeightStyle | the configuration for line height such as vertical alignment of the line, whether to apply additional space as a result of line height to top of first line top and bottom of last line. The configuration is applied only when a `lineHeight` is defined. |
| lineBreak | The line breaking configuration for the text. |
| hyphens | The configuration of hyphenation. |
| textMotion | Text character placement, whether to optimize for animated or static text. |



```kotlin
constructor(
    brush: Brush?,
    alpha: Float = Float.NaN,
    fontSize: TextUnit = TextUnit.Unspecified,
    fontWeight: FontWeight? = null,
    fontStyle: FontStyle? = null,
    fontSynthesis: FontSynthesis? = null,
    fontFamily: FontFamily? = null,
    fontFeatureSettings: String? = null,
    letterSpacing: TextUnit = TextUnit.Unspecified,
    baselineShift: BaselineShift? = null,
    textGeometricTransform: TextGeometricTransform? = null,
    localeList: LocaleList? = null,
    background: Color = Color.Unspecified,
    textDecoration: TextDecoration? = null,
    shadow: Shadow? = null,
    drawStyle: DrawStyle? = null,
    textAlign: TextAlign? = null,
    textDirection: TextDirection? = null,
    lineHeight: TextUnit = TextUnit.Unspecified,
    textIndent: TextIndent? = null,
    platformStyle: PlatformTextStyle? = null,
    lineHeightStyle: LineHeightStyle? = null,
    lineBreak: LineBreak? = null,
    hyphens: Hyphens? = null,
    textMotion: TextMotion? = null,
) : this(
    SpanStyle(
        brush = brush,
        alpha = alpha,
        fontSize = fontSize,
        fontWeight = fontWeight,
        fontStyle = fontStyle,
        fontSynthesis = fontSynthesis,
        fontFamily = fontFamily,
        fontFeatureSettings = fontFeatureSettings,
        letterSpacing = letterSpacing,
        baselineShift = baselineShift,
        textGeometricTransform = textGeometricTransform,
        localeList = localeList,
        background = background,
        textDecoration = textDecoration,
        shadow = shadow,
        platformStyle = platformStyle?.spanStyle,
        drawStyle = drawStyle,
    ),
    ParagraphStyle(
        textAlign = textAlign ?: TextAlign.Unspecified,
        textDirection = textDirection ?: TextDirection.Unspecified,
        lineHeight = lineHeight,
        textIndent = textIndent,
        platformStyle = platformStyle?.paragraphStyle,
        lineHeightStyle = lineHeightStyle,
        lineBreak = lineBreak ?: LineBreak.Unspecified,
        hyphens = hyphens ?: Hyphens.Unspecified,
        textMotion = textMotion,
    ),
    platformStyle = platformStyle,
)
```

## Properties

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


```kotlin
val brush: Brush?
```


The brush to use when drawing text. If not null, overrides `color`.



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


```kotlin
val color: Color
```


The text color.



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


```kotlin
val alpha: Float
```


Opacity of text. This value is either provided along side Brush, or via alpha channel in
color.



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


```kotlin
val fontSize: TextUnit
```


The size of glyphs to use when painting the text. This may be `TextUnit.Unspecified` for
inheriting from another `TextStyle`.



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


```kotlin
val fontWeight: FontWeight?
```


The typeface thickness to use when painting the text (e.g., bold).



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


```kotlin
val fontStyle: FontStyle?
```


The typeface variant to use when drawing the letters (e.g., italic).



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


```kotlin
val fontSynthesis: FontSynthesis?
```


Whether to synthesize font weight and/or style when the requested weight or style cannot be
found in the provided font family.



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


```kotlin
val fontFamily: FontFamily?
```


The font family to be used when rendering the text.



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


```kotlin
val fontFeatureSettings: String?
```


The advanced typography settings provided by font. The format is the same as the CSS
font-feature-settings attribute:
https://www.w3.org/TR/css-fonts-3/#font-feature-settings-prop



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


```kotlin
val letterSpacing: TextUnit
```


The amount of space to add between each letter.



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


```kotlin
val baselineShift: BaselineShift?
```


The amount by which the text is shifted up from the current baseline.



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


```kotlin
val textGeometricTransform: TextGeometricTransform?
```


The geometric transformation applied the text.



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


```kotlin
val localeList: LocaleList?
```


The locale list used to select region-specific glyphs.



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


```kotlin
val background: Color
```


The background color for the text.



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


```kotlin
val textDecoration: TextDecoration?
```


The decorations to paint on the text (e.g., an underline).



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


```kotlin
val shadow: Shadow?
```


The shadow effect applied on the text.



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


```kotlin
val drawStyle: DrawStyle?
```


Drawing style of text, whether fill in the text while drawing or stroke around the edges.



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


```kotlin
val textAlign: TextAlign
```


The alignment of the text within the lines of the paragraph.



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


> **Deprecated** Kept for backwards compatibility.

```kotlin
val deprecated_boxing_textAlign: TextAlign?
```


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


```kotlin
val textDirection: TextDirection
```


The algorithm to be used to resolve the final text and paragraph direction: Left To Right or
Right To Left. If no value is provided the system will use the `LayoutDirection` as the
primary signal.



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


> **Deprecated** Kept for backwards compatibility.

```kotlin
val deprecated_boxing_textDirection: TextDirection?
```


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


```kotlin
val lineHeight: TextUnit
```


Line height for the `Paragraph` in `TextUnit` unit, e.g. SP or EM.



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


```kotlin
val textIndent: TextIndent?
```


The indentation of the paragraph.



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


```kotlin
val lineHeightStyle: LineHeightStyle?
```


The configuration for line height such as vertical alignment of the line, whether to apply
additional space as a result of line height to top of first line top and bottom of last line.

The configuration is applied only when a `lineHeight` is defined.

When null, `LineHeightStyle.Default` is used.



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


```kotlin
val hyphens: Hyphens
```


The hyphens configuration of the paragraph.



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


> **Deprecated** Kept for backwards compatibility.

```kotlin
val deprecated_boxing_hyphens: Hyphens?
```


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


```kotlin
val lineBreak: LineBreak
```


The line breaking configuration of the paragraph.



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


> **Deprecated** Kept for backwards compatibility.

```kotlin
val deprecated_boxing_lineBreak: LineBreak?
```


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


```kotlin
val textMotion: TextMotion?
```


Text character placement configuration, whether to optimize for animated or static text.



## Functions

```kotlin
fun toSpanStyle(): SpanStyle
```

```kotlin
fun toParagraphStyle(): ParagraphStyle
```

```kotlin
fun merge(other: TextStyle? = null): TextStyle
```


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

`other` text style's null or inherit properties are replaced with the non-null properties of
this text style. Another way to think of it is that the "missing" properties of the `other`
style are _filled_ by the properties of this style.

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


```kotlin
fun merge(
        color: Color = Color.Unspecified,
        fontSize: TextUnit = TextUnit.Unspecified,
        fontWeight: FontWeight? = null,
        fontStyle: FontStyle? = null,
        fontSynthesis: FontSynthesis? = null,
        fontFamily: FontFamily? = null,
        fontFeatureSettings: String? = null,
        letterSpacing: TextUnit = TextUnit.Unspecified,
        baselineShift: BaselineShift? = null,
        textGeometricTransform: TextGeometricTransform? = null,
        localeList: LocaleList? = null,
        background: Color = Color.Unspecified,
        textDecoration: TextDecoration? = null,
        shadow: Shadow? = null,
        drawStyle: DrawStyle? = null,
        textAlign: TextAlign = TextAlign.Unspecified,
        textDirection: TextDirection = TextDirection.Unspecified,
        lineHeight: TextUnit = TextUnit.Unspecified,
        textIndent: TextIndent? = null,
        lineHeightStyle: LineHeightStyle? = null,
        lineBreak: LineBreak = LineBreak.Unspecified,
        hyphens: Hyphens = Hyphens.Unspecified,
        platformStyle: PlatformTextStyle? = null,
        textMotion: TextMotion? = null,
    ): TextStyle
```


Fast merge non-default values and parameters.

This is the same algorithm as `merge` but does not require allocating it's parameter and may
return this instead of allocating a result when all values are default.

This is a similar algorithm to `copy` but when either this or a parameter are set to a
default value, the other value will take precedent.

To explain better, consider the following examples:

Example 1:
- this.color = `Color.Unspecified`
- `color` = `Color.Red`
- result => `Color.Red`

Example 2:
- this.color = `Color.Red`
- `color` = `Color.Unspecified`
- result => `Color.Red`

Example 3:
- this.color = `Color.Red`
- `color` = `Color.Blue`
- result => `Color.Blue`

You should _always_ use this method over the `merge`(`TextStyle`) overload when you do not
already have a TextStyle allocated. You should chose this over `copy` when building a theming
system and applying styling information to a specific usage.

#### Returns

| | |
| --- | --- |
|  | this or a new TextLayoutResult with all parameters chosen to the non-default option provided. |



```kotlin
fun merge(
        color: Color = Color.Unspecified,
        fontSize: TextUnit = TextUnit.Unspecified,
        fontWeight: FontWeight? = null,
        fontStyle: FontStyle? = null,
        fontSynthesis: FontSynthesis? = null,
        fontFamily: FontFamily? = null,
        fontFeatureSettings: String? = null,
        letterSpacing: TextUnit = TextUnit.Unspecified,
        baselineShift: BaselineShift? = null,
        textGeometricTransform: TextGeometricTransform? = null,
        localeList: LocaleList? = null,
        background: Color = Color.Unspecified,
        textDecoration: TextDecoration? = null,
        shadow: Shadow? = null,
        drawStyle: DrawStyle? = null,
        textAlign: TextAlign? = null,
        textDirection: TextDirection? = null,
        lineHeight: TextUnit = TextUnit.Unspecified,
        textIndent: TextIndent? = null,
        lineHeightStyle: LineHeightStyle? = null,
        lineBreak: LineBreak? = null,
        hyphens: Hyphens? = null,
        platformStyle: PlatformTextStyle? = null,
        textMotion: TextMotion? = null,
    ): TextStyle
```

```kotlin
fun merge(other: SpanStyle): TextStyle
```


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


```kotlin
fun merge(other: ParagraphStyle): TextStyle
```


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


```kotlin
operator fun plus(other: TextStyle): TextStyle
```


Plus operator overload that applies a `merge`.


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


Plus operator overload that applies a `merge`.


```kotlin
operator fun plus(other: SpanStyle): TextStyle
```


Plus operator overload that applies a `merge`.


```kotlin
fun copy(
        color: Color = this.spanStyle.color,
        fontSize: TextUnit = this.spanStyle.fontSize,
        fontWeight: FontWeight? = this.spanStyle.fontWeight,
        fontStyle: FontStyle? = this.spanStyle.fontStyle,
        fontSynthesis: FontSynthesis? = this.spanStyle.fontSynthesis,
        fontFamily: FontFamily? = this.spanStyle.fontFamily,
        fontFeatureSettings: String? = this.spanStyle.fontFeatureSettings,
        letterSpacing: TextUnit = this.spanStyle.letterSpacing,
        baselineShift: BaselineShift? = this.spanStyle.baselineShift,
        textGeometricTransform: TextGeometricTransform? = this.spanStyle.textGeometricTransform,
        localeList: LocaleList? = this.spanStyle.localeList,
        background: Color = this.spanStyle.background,
        textDecoration: TextDecoration? = this.spanStyle.textDecoration,
        shadow: Shadow? = this.spanStyle.shadow,
        textAlign: TextAlign? = this.paragraphStyle.textAlign,
        textDirection: TextDirection? = this.paragraphStyle.textDirection,
        lineHeight: TextUnit = this.paragraphStyle.lineHeight,
        textIndent: TextIndent? = this.paragraphStyle.textIndent,
    ): TextStyle
```

```kotlin
fun copy(
        color: Color = this.spanStyle.color,
        fontSize: TextUnit = this.spanStyle.fontSize,
        fontWeight: FontWeight? = this.spanStyle.fontWeight,
        fontStyle: FontStyle? = this.spanStyle.fontStyle,
        fontSynthesis: FontSynthesis? = this.spanStyle.fontSynthesis,
        fontFamily: FontFamily? = this.spanStyle.fontFamily,
        fontFeatureSettings: String? = this.spanStyle.fontFeatureSettings,
        letterSpacing: TextUnit = this.spanStyle.letterSpacing,
        baselineShift: BaselineShift? = this.spanStyle.baselineShift,
        textGeometricTransform: TextGeometricTransform? = this.spanStyle.textGeometricTransform,
        localeList: LocaleList? = this.spanStyle.localeList,
        background: Color = this.spanStyle.background,
        textDecoration: TextDecoration? = this.spanStyle.textDecoration,
        shadow: Shadow? = this.spanStyle.shadow,
        textAlign: TextAlign? = this.paragraphStyle.textAlign,
        textDirection: TextDirection? = this.paragraphStyle.textDirection,
        lineHeight: TextUnit = this.paragraphStyle.lineHeight,
        textIndent: TextIndent? = this.paragraphStyle.textIndent,
        platformStyle: PlatformTextStyle? = this.platformStyle,
        lineHeightStyle: LineHeightStyle? = this.paragraphStyle.lineHeightStyle,
    ): TextStyle
```

```kotlin
fun copy(
        color: Color = this.spanStyle.color,
        fontSize: TextUnit = this.spanStyle.fontSize,
        fontWeight: FontWeight? = this.spanStyle.fontWeight,
        fontStyle: FontStyle? = this.spanStyle.fontStyle,
        fontSynthesis: FontSynthesis? = this.spanStyle.fontSynthesis,
        fontFamily: FontFamily? = this.spanStyle.fontFamily,
        fontFeatureSettings: String? = this.spanStyle.fontFeatureSettings,
        letterSpacing: TextUnit = this.spanStyle.letterSpacing,
        baselineShift: BaselineShift? = this.spanStyle.baselineShift,
        textGeometricTransform: TextGeometricTransform? = this.spanStyle.textGeometricTransform,
        localeList: LocaleList? = this.spanStyle.localeList,
        background: Color = this.spanStyle.background,
        textDecoration: TextDecoration? = this.spanStyle.textDecoration,
        shadow: Shadow? = this.spanStyle.shadow,
        textAlign: TextAlign? = this.paragraphStyle.textAlign,
        textDirection: TextDirection? = this.paragraphStyle.textDirection,
        lineHeight: TextUnit = this.paragraphStyle.lineHeight,
        textIndent: TextIndent? = this.paragraphStyle.textIndent,
        platformStyle: PlatformTextStyle? = this.platformStyle,
        lineHeightStyle: LineHeightStyle? = this.paragraphStyle.lineHeightStyle,
        lineBreak: LineBreak? = this.paragraphStyle.lineBreak,
        hyphens: Hyphens? = this.paragraphStyle.hyphens,
    ): TextStyle
```

```kotlin
fun copy(
        color: Color = this.spanStyle.color,
        fontSize: TextUnit = this.spanStyle.fontSize,
        fontWeight: FontWeight? = this.spanStyle.fontWeight,
        fontStyle: FontStyle? = this.spanStyle.fontStyle,
        fontSynthesis: FontSynthesis? = this.spanStyle.fontSynthesis,
        fontFamily: FontFamily? = this.spanStyle.fontFamily,
        fontFeatureSettings: String? = this.spanStyle.fontFeatureSettings,
        letterSpacing: TextUnit = this.spanStyle.letterSpacing,
        baselineShift: BaselineShift? = this.spanStyle.baselineShift,
        textGeometricTransform: TextGeometricTransform? = this.spanStyle.textGeometricTransform,
        localeList: LocaleList? = this.spanStyle.localeList,
        background: Color = this.spanStyle.background,
        textDecoration: TextDecoration? = this.spanStyle.textDecoration,
        shadow: Shadow? = this.spanStyle.shadow,
        drawStyle: DrawStyle? = this.spanStyle.drawStyle,
        textAlign: TextAlign? = this.paragraphStyle.textAlign,
        textDirection: TextDirection? = this.paragraphStyle.textDirection,
        lineHeight: TextUnit = this.paragraphStyle.lineHeight,
        textIndent: TextIndent? = this.paragraphStyle.textIndent,
        platformStyle: PlatformTextStyle? = this.platformStyle,
        lineHeightStyle: LineHeightStyle? = this.paragraphStyle.lineHeightStyle,
        lineBreak: LineBreak? = this.paragraphStyle.lineBreak,
        hyphens: Hyphens? = this.paragraphStyle.hyphens,
        textMotion: TextMotion? = this.paragraphStyle.textMotion,
    ): TextStyle
```

```kotlin
fun copy(
        color: Color = this.spanStyle.color,
        fontSize: TextUnit = this.spanStyle.fontSize,
        fontWeight: FontWeight? = this.spanStyle.fontWeight,
        fontStyle: FontStyle? = this.spanStyle.fontStyle,
        fontSynthesis: FontSynthesis? = this.spanStyle.fontSynthesis,
        fontFamily: FontFamily? = this.spanStyle.fontFamily,
        fontFeatureSettings: String? = this.spanStyle.fontFeatureSettings,
        letterSpacing: TextUnit = this.spanStyle.letterSpacing,
        baselineShift: BaselineShift? = this.spanStyle.baselineShift,
        textGeometricTransform: TextGeometricTransform? = this.spanStyle.textGeometricTransform,
        localeList: LocaleList? = this.spanStyle.localeList,
        background: Color = this.spanStyle.background,
        textDecoration: TextDecoration? = this.spanStyle.textDecoration,
        shadow: Shadow? = this.spanStyle.shadow,
        drawStyle: DrawStyle? = this.spanStyle.drawStyle,
        textAlign: TextAlign = this.paragraphStyle.textAlign,
        textDirection: TextDirection = this.paragraphStyle.textDirection,
        lineHeight: TextUnit = this.paragraphStyle.lineHeight,
        textIndent: TextIndent? = this.paragraphStyle.textIndent,
        platformStyle: PlatformTextStyle? = this.platformStyle,
        lineHeightStyle: LineHeightStyle? = this.paragraphStyle.lineHeightStyle,
        lineBreak: LineBreak = this.paragraphStyle.lineBreak,
        hyphens: Hyphens = this.paragraphStyle.hyphens,
        textMotion: TextMotion? = this.paragraphStyle.textMotion,
    ): TextStyle
```

```kotlin
fun copy(
        brush: Brush?,
        alpha: Float = this.spanStyle.alpha,
        fontSize: TextUnit = this.spanStyle.fontSize,
        fontWeight: FontWeight? = this.spanStyle.fontWeight,
        fontStyle: FontStyle? = this.spanStyle.fontStyle,
        fontSynthesis: FontSynthesis? = this.spanStyle.fontSynthesis,
        fontFamily: FontFamily? = this.spanStyle.fontFamily,
        fontFeatureSettings: String? = this.spanStyle.fontFeatureSettings,
        letterSpacing: TextUnit = this.spanStyle.letterSpacing,
        baselineShift: BaselineShift? = this.spanStyle.baselineShift,
        textGeometricTransform: TextGeometricTransform? = this.spanStyle.textGeometricTransform,
        localeList: LocaleList? = this.spanStyle.localeList,
        background: Color = this.spanStyle.background,
        textDecoration: TextDecoration? = this.spanStyle.textDecoration,
        shadow: Shadow? = this.spanStyle.shadow,
        drawStyle: DrawStyle? = this.spanStyle.drawStyle,
        textAlign: TextAlign? = this.paragraphStyle.textAlign,
        textDirection: TextDirection? = this.paragraphStyle.textDirection,
        lineHeight: TextUnit = this.paragraphStyle.lineHeight,
        textIndent: TextIndent? = this.paragraphStyle.textIndent,
        platformStyle: PlatformTextStyle? = this.platformStyle,
        lineHeightStyle: LineHeightStyle? = this.paragraphStyle.lineHeightStyle,
        lineBreak: LineBreak? = this.paragraphStyle.lineBreak,
        hyphens: Hyphens? = this.paragraphStyle.hyphens,
        textMotion: TextMotion? = this.paragraphStyle.textMotion,
    ): TextStyle
```

```kotlin
fun copy(
        brush: Brush?,
        alpha: Float = this.spanStyle.alpha,
        fontSize: TextUnit = this.spanStyle.fontSize,
        fontWeight: FontWeight? = this.spanStyle.fontWeight,
        fontStyle: FontStyle? = this.spanStyle.fontStyle,
        fontSynthesis: FontSynthesis? = this.spanStyle.fontSynthesis,
        fontFamily: FontFamily? = this.spanStyle.fontFamily,
        fontFeatureSettings: String? = this.spanStyle.fontFeatureSettings,
        letterSpacing: TextUnit = this.spanStyle.letterSpacing,
        baselineShift: BaselineShift? = this.spanStyle.baselineShift,
        textGeometricTransform: TextGeometricTransform? = this.spanStyle.textGeometricTransform,
        localeList: LocaleList? = this.spanStyle.localeList,
        background: Color = this.spanStyle.background,
        textDecoration: TextDecoration? = this.spanStyle.textDecoration,
        shadow: Shadow? = this.spanStyle.shadow,
        drawStyle: DrawStyle? = this.spanStyle.drawStyle,
        textAlign: TextAlign = this.paragraphStyle.textAlign,
        textDirection: TextDirection = this.paragraphStyle.textDirection,
        lineHeight: TextUnit = this.paragraphStyle.lineHeight,
        textIndent: TextIndent? = this.paragraphStyle.textIndent,
        platformStyle: PlatformTextStyle? = this.platformStyle,
        lineHeightStyle: LineHeightStyle? = this.paragraphStyle.lineHeightStyle,
        lineBreak: LineBreak = this.paragraphStyle.lineBreak,
        hyphens: Hyphens = this.paragraphStyle.hyphens,
        textMotion: TextMotion? = this.paragraphStyle.textMotion,
    ): TextStyle
```

```kotlin
fun hasSameLayoutAffectingAttributes(other: TextStyle): Boolean
```


Returns true if text layout affecting attributes between this TextStyle and other are the
same.

The attributes that do not require a layout change are color, textDecoration and shadow.

Majority of attributes change text layout, and examples are line height, font properties,
font size, locale etc.

This function can be used to identify if a new text layout is required for a given TextStyle.

#### Parameters

| | |
| --- | --- |
| other | The TextStyle to compare to. |



```kotlin
fun hasSameDrawAffectingAttributes(other: TextStyle): Boolean
```

## Companion Object

#### Properties

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


```kotlin
val Default = TextStyle()
```


Constant for default text style.





## Code Examples

### TextStyleSample
```kotlin
@Composable
fun TextStyleSample() {
    Text(
        text = "Demo Text",
        style =
            TextStyle(
                color = Color.Red,
                fontSize = 16.sp,
                fontFamily = FontFamily.Monospace,
                fontWeight = FontWeight.W800,
                fontStyle = FontStyle.Italic,
                letterSpacing = 0.5.em,
                background = Color.LightGray,
                textDecoration = TextDecoration.Underline,
            ),
    )
}
```

