---
title: "staticCompositionLocalWithComputedDefaultOf"
description: "Create a [CompositionLocal] that behaves like it was provided using [ProvidableCompositionLocal.providesComputed] by default."
type: "function"
---
## API Reference

### staticCompositionLocalWithComputedDefaultOf

> Source set: Common

```kotlin
public fun <T> staticCompositionLocalWithComputedDefaultOf(
    defaultComputation: CompositionLocalAccessorScope.() -> T
): ProvidableCompositionLocal<T>
```

Create a [CompositionLocal](/jetpack-compose/androidx.compose.runtime/runtime/classes/CompositionLocal/api) that behaves like it was provided using
`ProvidableCompositionLocal.providesComputed` by default. If a value is provided using
`ProvidableCompositionLocal.provides` it behaves as if the [CompositionLocal](/jetpack-compose/androidx.compose.runtime/runtime/classes/CompositionLocal/api) was produced by
calling [staticCompositionLocalOf](/jetpack-compose/androidx.compose.runtime/runtime/functions/staticCompositionLocalOf/api).

Unlike [compositionLocalWithComputedDefaultOf](/jetpack-compose/androidx.compose.runtime/runtime/functions/compositionLocalWithComputedDefaultOf/api), reads of a provided value for
[staticCompositionLocalWithComputedDefaultOf](/jetpack-compose/androidx.compose.runtime/runtime/functions/staticCompositionLocalWithComputedDefaultOf/api) are not tracked by the composer and changing the
value provided in the [CompositionLocalProvider](/jetpack-compose/androidx.compose.runtime/runtime/composable-functions/CompositionLocalProvider/api) call will cause the entirety of the content to
be recomposed instead of just the places where in the composition the local value is used. This
lack of tracking, however, makes a [staticCompositionLocalWithComputedDefaultOf](/jetpack-compose/androidx.compose.runtime/runtime/functions/staticCompositionLocalWithComputedDefaultOf/api) more efficient
when the value provided is highly unlikely to or will never change. For example, the android
context, font loaders, or similar shared values, are unlikely to change for the components in the
content of a the [CompositionLocalProvider](/jetpack-compose/androidx.compose.runtime/runtime/composable-functions/CompositionLocalProvider/api) and should consider using a
[staticCompositionLocalWithComputedDefaultOf](/jetpack-compose/androidx.compose.runtime/runtime/functions/staticCompositionLocalWithComputedDefaultOf/api). A color, or other theme like value, might change
or even be animated therefore a [compositionLocalWithComputedDefaultOf](/jetpack-compose/androidx.compose.runtime/runtime/functions/compositionLocalWithComputedDefaultOf/api) should be used.

Reads of the computed value are tracked and modifying the computed value results in only the
invalidated parts of the composition being recomposed.

[staticCompositionLocalWithComputedDefaultOf](/jetpack-compose/androidx.compose.runtime/runtime/functions/staticCompositionLocalWithComputedDefaultOf/api) creates a [ProvidableCompositionLocal](/jetpack-compose/androidx.compose.runtime/runtime/classes/ProvidableCompositionLocal/api) which can be
used in a call to [CompositionLocalProvider](/jetpack-compose/androidx.compose.runtime/runtime/composable-functions/CompositionLocalProvider/api). Similar to `MutableList` vs. `List`, if the key is
made public as [CompositionLocal](/jetpack-compose/androidx.compose.runtime/runtime/classes/CompositionLocal/api) instead of [ProvidableCompositionLocal](/jetpack-compose/androidx.compose.runtime/runtime/classes/ProvidableCompositionLocal/api), it can be read using
`CompositionLocal.current` but not re-provided.

#### Parameters

| | |
| --- | --- |
| defaultComputation | default computation to run when this [CompositionLocal](/jetpack-compose/androidx.compose.runtime/runtime/classes/CompositionLocal) is not provided |
