Components / App structure

Navigation Bar

Explore bar placement and navigation state in a full screen.

CupertinoNavigationBar View source ↗

Playground

Live Compose · Wasm
Preview

Click or drag inside the preview to try it out.

Properties

Usage example

Kotlin code for the current playground settings.

Example.kt
kotlin
import androidx.compose.runtime.*import androidx.compose.foundation.layout.*import androidx.compose.ui.Modifierimport androidx.compose.ui.unit.dpimport zone.ien.hig.*import zone.ien.hig.theme.*import zone.ien.hig.icons.CupertinoIconsimport zone.ien.hig.icons.filled.Heartimport androidx.compose.foundation.Imageimport androidx.compose.ui.layout.ContentScaleimport org.jetbrains.compose.resources.painterResourceimport zone.ien.hig.composeapp.generated.resources.Resimport zone.ien.hig.composeapp.generated.resources.glass_landscapeimport androidx.compose.foundation.backgroundimport com.kyant.backdrop.backdrops.rememberLayerBackdropimport com.kyant.backdrop.backdrops.layerBackdropimport androidx.compose.ui.graphics.Colorimport androidx.compose.ui.Alignment
@OptIn(ExperimentalCupertinoApi::class)@Composablefun Example() { CupertinoTheme(colorScheme = lightColorScheme(accent = Color(0xFF007AFF))) { val backdrop = rememberLayerBackdrop() Box(Modifier.fillMaxSize()) { Image(painterResource(Res.drawable.glass_landscape), contentDescription = null, modifier = Modifier.matchParentSize().layerBackdrop(backdrop), contentScale = ContentScale.Crop) Column(Modifier.fillMaxSize(), verticalArrangement = Arrangement.spacedBy(16.dp, Alignment.CenterVertically)) { var selected by remember { mutableIntStateOf(0) } CupertinoNavigationBar( backdrop = backdrop, selectedTabIndex = { selected }, onTabSelected = { selected = it }, tabsCount = 3, ) { listOf("Home", "Favorites", "Settings").forEachIndexed { index, title -> CupertinoNavigationBarItem( onClick = { selected = index }, icon = { CupertinoIcon(CupertinoIcons.Filled.Heart, contentDescription = null) }, label = { CupertinoText(title) }, ) } } } } }}

Run examples inside CupertinoTheme. For components using backdrop, attach layerBackdrop to the background content.

The background uses the sample app's glass_landscape resource. Replace it with an image from your project.