Use a navigation bar when users need to move between a small set of primary destinations.
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.composables.icons.lucide.Bell
import com.composables.icons.lucide.Heart
import com.composables.icons.lucide.Lucide
import com.composables.icons.lucide.Plus
import com.composables.icons.lucide.Search
import com.composables.ui.components.Icon
import com.composables.ui.components.NavigationBar
import com.composables.ui.components.NavigationBarItem
@Composable
fun NavigationBarExample() {
var selectedItem by remember { mutableStateOf("Feed") }
NavigationBar(modifier = Modifier.fillMaxWidth()) {
NavigationBarItem(
selected = selectedItem == "Feed",
onClick = { selectedItem = "Feed" },
modifier = Modifier.weight(1f),
) {
Icon(Lucide.Heart, contentDescription = "Feed", modifier = Modifier.size(20.dp))
}
NavigationBarItem(
selected = selectedItem == "Search",
onClick = { selectedItem = "Search" },
modifier = Modifier.weight(1f),
) {
Icon(Lucide.Search, contentDescription = "Search", modifier = Modifier.size(20.dp))
}
NavigationBarItem(
selected = selectedItem == "Create",
onClick = { selectedItem = "Create" },
modifier = Modifier.weight(1f),
) {
Icon(Lucide.Plus, contentDescription = "Create", modifier = Modifier.size(20.dp))
}
NavigationBarItem(
selected = selectedItem == "Activity",
onClick = { selectedItem = "Activity" },
modifier = Modifier.weight(1f),
) {
Icon(Lucide.Bell, contentDescription = "Activity", modifier = Modifier.size(20.dp))
}
}
}Installation
implementation("com.composables:ui:0.2.0")Add the required dependencies
implementation("com.composables:composeunstyled:2.7.0")
Copy and paste the following sources into your project
components/NavigationBar.kt
/*
* Copyright (c) 2026 Composable Horizons
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.composables.ui.components
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.systemBars
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.unit.dp
import com.composables.ui.theme.colors
import com.composables.ui.theme.onPanelColor
import com.composables.ui.theme.onSelectedControlColor
import com.composables.ui.theme.panelColor
import com.composables.ui.theme.selectedControlColor
import com.composeunstyled.ProvideContentColor
import com.composeunstyled.buildModifier
import com.composeunstyled.theme.Theme
/**
* A bottom navigation bar container.
* @param modifier Modifier applied to the component.
* @param windowInsets Insets applied around the navigation bar content.
* @param content Composable content displayed by the component.
*/
@Composable
fun NavigationBar(
modifier: Modifier = Modifier,
windowInsets: WindowInsets = navigationBarWindowInsets(),
content: @Composable RowScope.() -> Unit,
) {
Column(
modifier
.pointerInput(Unit) {}
.background(Theme[colors][panelColor]),
) {
HorizontalSeparator()
Row(
modifier = Modifier
.windowInsetsPadding(windowInsets)
.height(NavigationBarHeight)
.padding(horizontal = 24.dp, vertical = 2.dp),
horizontalArrangement = Arrangement.spacedBy(NavigationBarItemSpacing),
verticalAlignment = Alignment.CenterVertically,
content = content,
)
}
}
/**
* A single destination action inside a navigation bar.
* @param selected Whether the navigation item is currently selected.
* @param onClick Called when the navigation item is activated.
* @param modifier Modifier applied to the component.
* @param enabled Whether the navigation item can be interacted with.
* @param shape Shape used for the selected navigation item background.
* @param content Composable content displayed by the component.
*/
@Composable
fun NavigationBarItem(
selected: Boolean,
onClick: () -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
shape: Shape = RoundedCornerShape(8.dp),
content: @Composable () -> Unit,
) {
IconButton(
onClick = onClick,
modifier = modifier then buildModifier {
if (selected) {
add(Modifier.background(Theme[colors][selectedControlColor], shape))
}
}.height(NavigationBarHeight),
enabled = enabled,
style = ButtonStyle.Ghost,
shape = shape,
) {
ProvideContentColor(if (selected) Theme[colors][onSelectedControlColor] else Theme[colors][onPanelColor]) {
content()
}
}
}
private val NavigationBarHeight = 64.dp
private val NavigationBarItemSpacing = 8.dp
@Composable
private fun navigationBarWindowInsets(): WindowInsets {
return WindowInsets.systemBars.only(WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom)
}components/Utils.kt
/*
* Copyright (c) 2026 Composable Horizons
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.composables.ui.components
import androidx.compose.animation.core.Spring
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.spring
import androidx.compose.animation.core.tween
import androidx.compose.foundation.interaction.InteractionSource
import androidx.compose.foundation.interaction.collectIsFocusedAsState
import androidx.compose.foundation.interaction.collectIsPressedAsState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.composables.ui.theme.colors
import com.composables.ui.theme.ringColor
import com.composeunstyled.FocusRingVisibility
import com.composeunstyled.collectIsFocusVisibleAsState
import com.composeunstyled.outline
import com.composeunstyled.theme.Theme
@Composable
fun Modifier.focusRing(
interactionSource: InteractionSource,
width: Dp = 2.dp,
color: Color = Theme[colors][ringColor],
shape: Shape = RectangleShape,
offset: Dp = 0.dp,
visibility: FocusRingVisibility = FocusRingVisibility.FocusVisible,
): Modifier {
val showFocusRing by if (visibility == FocusRingVisibility.FocusVisible) {
interactionSource.collectIsFocusVisibleAsState()
} else {
interactionSource.collectIsFocusedAsState()
}
val animatedWidth by animateDpAsState(
targetValue = if (showFocusRing) width else 0.dp,
animationSpec = tween(durationMillis = 120),
label = "FocusRingWidth",
)
return this then Modifier.outline(
width = animatedWidth,
color = color,
shape = shape,
offset = offset,
)
}
@Composable
fun Modifier.bouncyPress(
interactionSource: InteractionSource,
enabled: Boolean = true,
pressedScale: Float = 0.98f,
): Modifier {
val pressed by interactionSource.collectIsPressedAsState()
val scale by animateFloatAsState(
targetValue = if (enabled && pressed) pressedScale else 1f,
animationSpec = spring(
dampingRatio = Spring.DampingRatioMediumBouncy,
stiffness = Spring.StiffnessMediumLow,
),
label = "BouncyPressScale",
)
return this then Modifier.graphicsLayer {
scaleX = scale
scaleY = scale
}
}Examples
Disabled items
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.composables.icons.lucide.Bell
import com.composables.icons.lucide.Heart
import com.composables.icons.lucide.Lucide
import com.composables.icons.lucide.Plus
import com.composables.icons.lucide.Search
import com.composables.ui.components.Icon
import com.composables.ui.components.NavigationBar
import com.composables.ui.components.NavigationBarItem
@Composable
fun DisabledNavigationBarExample() {
var selectedItem by remember { mutableStateOf("Feed") }
NavigationBar(modifier = Modifier.fillMaxWidth()) {
NavigationBarItem(
selected = selectedItem == "Feed",
onClick = { selectedItem = "Feed" },
modifier = Modifier.weight(1f),
) {
Icon(Lucide.Heart, contentDescription = "Feed", modifier = Modifier.size(20.dp))
}
NavigationBarItem(
selected = selectedItem == "Search",
onClick = { selectedItem = "Search" },
modifier = Modifier.weight(1f),
) {
Icon(Lucide.Search, contentDescription = "Search", modifier = Modifier.size(20.dp))
}
NavigationBarItem(
selected = false,
onClick = { selectedItem = "Create" },
enabled = false,
modifier = Modifier.weight(1f),
) {
Icon(Lucide.Plus, contentDescription = "Create", modifier = Modifier.size(20.dp))
}
NavigationBarItem(
selected = false,
onClick = { selectedItem = "Activity" },
enabled = false,
modifier = Modifier.weight(1f),
) {
Icon(Lucide.Bell, contentDescription = "Activity", modifier = Modifier.size(20.dp))
}
}
}Custom insets
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.composables.icons.lucide.Bell
import com.composables.icons.lucide.Heart
import com.composables.icons.lucide.Lucide
import com.composables.icons.lucide.Plus
import com.composables.icons.lucide.Search
import com.composables.ui.components.Icon
import com.composables.ui.components.NavigationBar
import com.composables.ui.components.NavigationBarItem
@Composable
fun CustomInsetsNavigationBarExample() {
var selectedItem by remember { mutableStateOf("Feed") }
NavigationBar(
modifier = Modifier.fillMaxWidth(),
windowInsets = WindowInsets(bottom = 32.dp),
) {
NavigationBarItem(
selected = selectedItem == "Feed",
onClick = { selectedItem = "Feed" },
modifier = Modifier.weight(1f),
) {
Icon(Lucide.Heart, contentDescription = "Feed", modifier = Modifier.size(20.dp))
}
NavigationBarItem(
selected = selectedItem == "Search",
onClick = { selectedItem = "Search" },
modifier = Modifier.weight(1f),
) {
Icon(Lucide.Search, contentDescription = "Search", modifier = Modifier.size(20.dp))
}
NavigationBarItem(
selected = selectedItem == "Create",
onClick = { selectedItem = "Create" },
modifier = Modifier.weight(1f),
) {
Icon(Lucide.Plus, contentDescription = "Create", modifier = Modifier.size(20.dp))
}
NavigationBarItem(
selected = selectedItem == "Activity",
onClick = { selectedItem = "Activity" },
modifier = Modifier.weight(1f),
) {
Icon(Lucide.Bell, contentDescription = "Activity", modifier = Modifier.size(20.dp))
}
}
}API Reference
NavigationBar
A bottom navigation bar container.
@Composable
fun NavigationBar(
modifier: Modifier = Modifier,
windowInsets: WindowInsets = navigationBarWindowInsets(),
content: @Composable RowScope.() -> Unit,
)
| Parameter | Type | Description |
|---|---|---|
modifier |
Modifier |
Modifier applied to the component. |
windowInsets |
WindowInsets |
Insets applied around the navigation bar content. |
content |
@Composable RowScope.() -> Unit |
Composable content displayed by the component. |
NavigationBarItem
A single destination action inside a navigation bar.
@Composable
fun NavigationBarItem(
selected: Boolean,
onClick: () -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
shape: Shape = RoundedCornerShape(8.dp),
content: @Composable () -> Unit,
)
| Parameter | Type | Description |
|---|---|---|
selected |
Boolean |
Whether the navigation item is currently selected. |
onClick |
() -> Unit |
Called when the navigation item is activated. |
modifier |
Modifier |
Modifier applied to the component. |
enabled |
Boolean |
Whether the navigation item can be interacted with. |
shape |
Shape |
Shape used for the selected navigation item background. |
content |
@Composable () -> Unit |
Composable content displayed by the component. |