---
title: "AmbientMode"
description: "Represents the current ambient mode of the device.

Example of using [AmbientMode] in a simple use case:"
type: "class"
---

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


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

<div class='sourceset sourceset-android'>Android</div>


```kotlin
public abstract class AmbientMode private constructor()
```


Represents the current ambient mode of the device.

Example of using `AmbientMode` in a simple use case:



## Code Examples

### AmbientModeBasicSample
```kotlin
@Composable
fun AmbientModeBasicSample() {
    // **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)
        }
    }
}
```

