# paddingFromBaseline

Common/AllAndroid/JVM

## Functions summary

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier.https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/paddingFromBaseline.modifier#(androidx.compose.ui.Modifier).paddingFromBaseline(androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)(top: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp, bottom: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp)` A `https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier` that positions the content in a layout such that the distance from the top of the layout to the `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/package-summary#FirstBaseline()` is `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.ui.Modifier).paddingFromBaseline(androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)`, and the distance from the `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/package-summary#LastBaseline()` to the bottom of the layout is `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.ui.Modifier).paddingFromBaseline(androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier.https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/paddingFromBaseline.modifier#(androidx.compose.ui.Modifier).paddingFromBaseline(androidx.compose.ui.unit.TextUnit,androidx.compose.ui.unit.TextUnit)(top: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit, bottom: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit)` A `https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier` that positions the content in a layout such that the distance from the top of the layout to the `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/package-summary#FirstBaseline()` is `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.ui.Modifier).paddingFromBaseline(androidx.compose.ui.unit.TextUnit,androidx.compose.ui.unit.TextUnit)`, and the distance from the `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/package-summary#LastBaseline()` to the bottom of the layout is `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.ui.Modifier).paddingFromBaseline(androidx.compose.ui.unit.TextUnit,androidx.compose.ui.unit.TextUnit)`. | Cmn |

## Functions

### Modifier.paddingFromBaseline

Cmn Artifact: [androidx.compose.foundation:foundation-layout](https://developer.android.com/jetpack/androidx/releases/compose-foundation) [View Source](https://cs.android.com/search?q=file:androidx/compose/foundation/layout/AlignmentLine.kt+function:paddingFromBaseline) Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.10.0)

```
fun Modifier.paddingFromBaseline(
    top: Dp = Dp.Unspecified,
    bottom: Dp = Dp.Unspecified
): Modifier
```

A `https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier` that positions the content in a layout such that the distance from the top of the layout to the `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/package-summary#FirstBaseline()` is `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.ui.Modifier).paddingFromBaseline(androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)`, and the distance from the `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/package-summary#LastBaseline()` to the bottom of the layout is `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.ui.Modifier).paddingFromBaseline(androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)`.

When the modified layout is min height constrained and the padded layout is smaller than the constraint, the modified layout will satisfy the min constraint and the content will be positioned to satisfy the `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.ui.Modifier).paddingFromBaseline(androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)` requirement if specified, or the `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.ui.Modifier).paddingFromBaseline(androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)` requirement otherwise.

Example usage:

```kotlin
import androidx.compose.foundation.layout.paddingFrom
import androidx.compose.foundation.layout.paddingFromBaseline
import androidx.compose.material3.Text
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.FirstBaseline
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp

// We want to have 30.dp distance from the top of the layout box to the baseline of the
// first line of text, and a 40.dp distance from the bottom of the layout box to the baseline
// of the last line of text. Note it is good practice to specify these distances in sp for font
// scaling, which can be done with the other overload.
val distanceToFirstBaseline = 30.dp
val distanceFromLastBaseline = 40.dp
Text(
    text = "This line has the first baseline.\nThis line has the last baseline.",
    modifier = Modifier.paddingFromBaseline(distanceToFirstBaseline, distanceFromLastBaseline),
)
```

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/paddingFrom.modifier#(androidx.compose.ui.Modifier).paddingFrom(androidx.compose.ui.layout.AlignmentLine,androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)` |   |

### Modifier.paddingFromBaseline

Cmn Artifact: [androidx.compose.foundation:foundation-layout](https://developer.android.com/jetpack/androidx/releases/compose-foundation) [View Source](https://cs.android.com/search?q=file:androidx/compose/foundation/layout/AlignmentLine.kt+function:paddingFromBaseline) Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.10.0)

```
fun Modifier.paddingFromBaseline(
    top: TextUnit = TextUnit.Unspecified,
    bottom: TextUnit = TextUnit.Unspecified
): Modifier
```

A `https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier` that positions the content in a layout such that the distance from the top of the layout to the `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/package-summary#FirstBaseline()` is `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.ui.Modifier).paddingFromBaseline(androidx.compose.ui.unit.TextUnit,androidx.compose.ui.unit.TextUnit)`, and the distance from the `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/package-summary#LastBaseline()` to the bottom of the layout is `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.ui.Modifier).paddingFromBaseline(androidx.compose.ui.unit.TextUnit,androidx.compose.ui.unit.TextUnit)`.

When the modified layout is min height constrained and the padded layout is smaller than the constraint, the modified layout will satisfy the min constraint and the content will be positioned to satisfy the `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.ui.Modifier).paddingFromBaseline(androidx.compose.ui.unit.TextUnit,androidx.compose.ui.unit.TextUnit)` requirement if specified, or the `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.ui.Modifier).paddingFromBaseline(androidx.compose.ui.unit.TextUnit,androidx.compose.ui.unit.TextUnit)` requirement otherwise.

Example usage:

```kotlin
import androidx.compose.foundation.layout.paddingFrom
import androidx.compose.foundation.layout.paddingFromBaseline
import androidx.compose.material3.Text
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.FirstBaseline
import androidx.compose.ui.unit.sp

// We want to have 30.sp distance from the top of the layout box to the baseline of the
// first line of text, and a 40.sp distance from the bottom of the layout box to the baseline
// of the last line of text.
val distanceToFirstBaseline = 30.sp
val distanceFromLastBaseline = 40.sp
Text(
    text = "This line has the first baseline.\nThis line has the last baseline.",
    modifier = Modifier.paddingFromBaseline(distanceToFirstBaseline, distanceFromLastBaseline),
)
```

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/paddingFrom.modifier#(androidx.compose.ui.Modifier).paddingFrom(androidx.compose.ui.layout.AlignmentLine,androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)` |   |