---
title: "LocalDensity"
description: "Provides the [Density] to be used to transform between
[density-independent pixel units (DP)][androidx.compose.ui.unit.Dp] and pixel units or
[scale-independent pixel units (SP)][androidx.compose.ui.unit.TextUnit] and pixel units. This is
typically used when a [DP][androidx.compose.ui.unit.Dp] is provided and it must be converted in
the body of [Layout] or [DrawModifier]."
type: "property"
---

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


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

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


```kotlin
val LocalDensity = staticCompositionLocalOf<Density> { noLocalProvidedFor("LocalDensity") }
```


Provides the `Density` to be used to transform between
`density-independent pixel units (DP)` and pixel units or
`scale-independent pixel units (SP)` and pixel units. This is
typically used when a `DP` is provided and it must be converted in
the body of `Layout` or `DrawModifier`.



