StatusBarSuppression

Functions summary

Unit

Suppresses the system status bar within full-screen or overlay components.

Unit

Suppresses the system status bar for all composables within content.

Functions

StatusBarSuppression

@Composable
fun StatusBarSuppression(): Unit

Suppresses the system status bar within full-screen or overlay components.

Call this within a component (such as TimePicker or a full-screen progress indicator) or inside a ScreenScaffold content block to suppress the status bar while that component is active. When leaving composition, the previous status bar visibility is automatically restored.

Placement: Place this inside the ScreenScaffold of the screen that requires suppression, or inside a component rendered on that screen. To wrap and suppress a ScreenScaffold, use the StatusBarSuppression overload that accepts a content lambda instead.

Inside an AppScaffold, suppresses the system status bar and coordinates with underlying screens. Outside an AppScaffold, hides the status bar directly on the current window and restores the initial visibility state when leaving composition.

An example of suppressing the status bar from within a component:

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.ui.Modifier
import androidx.wear.compose.material3.CircularProgressIndicator
import androidx.wear.compose.material3.CircularProgressIndicatorDefaults
import androidx.wear.compose.material3.MaterialTheme
import androidx.wear.compose.material3.StatusBarSuppression

// Suppress the status bar to avoid overlapping with the full-screen circular progress
// indicator.
StatusBarSuppression()

Box(
    modifier =
        Modifier.background(MaterialTheme.colorScheme.background)
            .padding(CircularProgressIndicatorDefaults.FullScreenPadding)
            .fillMaxSize()
) {
    CircularProgressIndicator(progress = { 0.75f }, startAngle = 120f, endAngle = 60f)
}

StatusBarSuppression

@Composable
fun StatusBarSuppression(content: @Composable () -> Unit): Unit

Suppresses the system status bar for all composables within content.

Use this overload to wrap a ScreenScaffold (or multiple screen destinations) to enforce status bar suppression. Child ScreenScaffolds within content inherit the suppression, hiding the status bar and automatically setting their top status bar inset padding to 0.dp.

Placement: Place this around a ScreenScaffold or around navigation destinations. For suppressing the status bar from within an individual component or screen body, use the zero-argument StatusBarSuppression overload instead.

Inside an AppScaffold, suppresses the system status bar and coordinates with underlying screens. Outside an AppScaffold, hides the status bar directly on the current window and restores the initial visibility state when leaving composition.

An example of wrapping a screen with StatusBarSuppression:

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.ui.Modifier
import androidx.wear.compose.material3.CircularProgressIndicator
import androidx.wear.compose.material3.CircularProgressIndicatorDefaults
import androidx.wear.compose.material3.MaterialTheme
import androidx.wear.compose.material3.ScreenScaffold
import androidx.wear.compose.material3.StatusBarSuppression

// Suppress the status bar for a screen and its children.
StatusBarSuppression {
    ScreenScaffold {
        Box(
            modifier =
                Modifier.background(MaterialTheme.colorScheme.background)
                    .padding(CircularProgressIndicatorDefaults.FullScreenPadding)
                    .fillMaxSize()
        ) {
            CircularProgressIndicator(progress = { 0.75f }, startAngle = 120f, endAngle = 60f)
        }
    }
}