---
title: Text
description: Styled text that inherits local typography and content color by default.
---

Use text for labels, titles, body copy, and inline content that should stay consistent with the surrounding theme.

<UiDemo id="text" />

## Installation

<Tabs>
<Tab title="Gradle">
```kotlin title="app/build.gradle.kts"
implementation("com.composables:ui:0.1.0")
```
</Tab>
<Tab title="Copy & Paste">
#### Add the required dependencies

```kotlin title="app/build.gradle.kts"
implementation("com.composables:composeunstyled:2.7.0")
```

#### Copy and paste the following sources into your project

<ComponentSource file="components/Text.kt" />
<ComponentSource file="components/Utils.kt" />
</Tab>
</Tabs>

## Examples

### Styled

<UiDemo id="text-styled" />

### Themed

<UiDemo id="text-themed" />

## API Reference

### Text

A styled text primitive that inherits local typography and content color.

```kotlin
@Composable
fun Text(
    text: String,
    modifier: Modifier = Modifier,
    style: TextStyle = LocalTextStyle.current,
    textAlign: TextAlign = TextAlign.Unspecified,
    lineHeight: TextUnit = TextUnit.Unspecified,
    fontSize: TextUnit = style.fontSize,
    letterSpacing: TextUnit = style.letterSpacing,
    fontWeight: FontWeight? = style.fontWeight,
    color: Color = if (style.color.isSpecified) style.color else LocalContentColor.current,
    fontFamily: FontFamily? = style.fontFamily,
    singleLine: Boolean = false,
    minLines: Int = 1,
    maxLines: Int = if (singleLine) 1 else Int.MAX_VALUE,
    overflow: TextOverflow = TextOverflow.Clip,
)
```

| Parameter | Type | Description |
|-----------|------|-------------|
| `text` | `String` | String content displayed by the text component. |
| `modifier` | `Modifier` | Modifier applied to the text. |
| `style` | `TextStyle` | Base text style used when drawing the text. |
| `textAlign` | `TextAlign` | Alignment used for the text within its bounds. |
| `lineHeight` | `TextUnit` | Line height used for the text. |
| `fontSize` | `TextUnit` | Font size used for the text. |
| `letterSpacing` | `TextUnit` | Letter spacing used for the text. |
| `fontWeight` | `FontWeight?` | Font weight used for the text. |
| `color` | `Color` | Color used to draw the text. |
| `fontFamily` | `FontFamily?` | Font family used for the text. |
| `singleLine` | `Boolean` | Whether the text is forced onto a single line. |
| `minLines` | `Int` | Minimum number of lines reserved for the text. |
| `maxLines` | `Int` | Maximum number of lines allowed for the text. |
| `overflow` | `TextOverflow` | How overflowing text should be handled. |

