# AmbientMode

Artifact: [androidx.wear.compose:compose-foundation](https://developer.android.com/jetpack/androidx/releases/wear-compose) [View Source](https://cs.android.com/search?q=file:androidx/wear/compose/foundation/AmbientMode.kt+class:androidx.wear.compose.foundation.AmbientMode) Added in [1.6.0](https://developer.android.com/jetpack/androidx/releases/wear-compose#1.6.0)


```
abstract class AmbientMode
```

<br />

Known direct subclasses [AmbientMode.Ambient](https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/AmbientMode.Ambient), [AmbientMode.Interactive](https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/AmbientMode.Interactive)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/AmbientMode.Ambient` | Represents that device is in the ambient mode. |
| `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/AmbientMode.Interactive` | Represents the mode when the user is actively interacting with the device. |

*** ** * ** ***

Represents the current ambient mode of the device.

Example of using `https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/AmbientMode` in a simple use case:

```kotlin
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.wear.compose.foundation.AmbientMode
import androidx.wear.compose.foundation.LocalAmbientModeManager
import androidx.wear.compose.foundation.rememberAmbientModeManager
import androidx.wear.compose.material.Text

// **Best Practice Note:** In a production application, the AmbientModeManager should be
// instantiated and provided at the highest level of the Compose hierarchy (typically in
// the host Activity's setContent block) using a CompositionLocalProvider. This ensures
// proper lifecycle management and broad accessibility.

// For this self-contained demo, AmbientModeManager is created and provided locally:
val activityAmbientModeManager = rememberAmbientModeManager()
CompositionLocalProvider(LocalAmbientModeManager provides activityAmbientModeManager) {
    val ambientModeManager = LocalAmbientModeManager.current
    val ambientMode = ambientModeManager?.currentAmbientMode
    Column(
        verticalArrangement = Arrangement.Center,
        horizontalAlignment = Alignment.CenterHorizontally,
        modifier = Modifier.fillMaxSize(),
    ) {
        val ambientModeName =
            when (ambientMode) {
                is AmbientMode.Interactive -> "Interactive"
                is AmbientMode.Ambient -> "Ambient"
                else -> "Unknown"
            }

        val color = if (ambientMode is AmbientMode.Ambient) Color.Gray else Color.Yellow
        Text(text = "$ambientModeName Mode", color = color)
    }
}
```

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/AmbientMode.Ambient : https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/AmbientMode` Represents that device is in the ambient mode. |
| `object https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/AmbientMode.Interactive : https://developer.android.com/reference/kotlin/androidx/wear/compose/foundation/AmbientMode` Represents the mode when the user is actively interacting with the device. |