Skip to content

Instantly share code, notes, and snippets.

@wakoliVotes
Created February 22, 2023 10:43
Show Gist options
  • Save wakoliVotes/41ab406e18756386a92785cfbdbaced8 to your computer and use it in GitHub Desktop.
Save wakoliVotes/41ab406e18756386a92785cfbdbaced8 to your computer and use it in GitHub Desktop.
Bottom Navigation for Jetpack Compose
// Bottom navigation bar with icons for home, about us, settings and profile
Spacer(modifier = Modifier.height(20.dp))
BottomNavigation(
backgroundColor = Color.White,
modifier = Modifier
.fillMaxWidth()
.height(56.dp)
) {
BottomNavigationItem(
icon = {
Icon(
imageVector = Icons.Default.Home,
contentDescription = "Home",
tint = Color.Black,
modifier = Modifier.size(24.dp)
)
},
label = { Text(text = "Home") },
selected = true,
onClick = { /*TODO*/ },
alwaysShowLabel = false,
selectedContentColor = Color.Black,
unselectedContentColor = Color.Gray,
)
BottomNavigationItem(
icon = {
Icon(
imageVector = Icons.Default.Info,
contentDescription = "About Us",
tint = Color.Black,
modifier = Modifier.size(24.dp)
)
},
label = { Text(text = "About Us") },
selected = false,
onClick = { /*TODO*/ },
alwaysShowLabel = true,
selectedContentColor = Color.Black,
unselectedContentColor = Color.Gray,
)
BottomNavigationItem(
icon = {
Icon(
imageVector = Icons.Default.Settings,
contentDescription = "Settings",
tint = Color.Black,
modifier = Modifier.size(24.dp)
)
},
label = { Text(text = "Settings") },
selected = true,
onClick = { /*TODO*/ },
alwaysShowLabel = false,
selectedContentColor = Color.Black,
unselectedContentColor = Color.Gray,
)
BottomNavigationItem(
icon = {
Icon(
imageVector = Icons.Default.Person,
contentDescription = "Profile",
tint = Color.Black,
modifier = Modifier.size(24.dp)
)
},
label = { Text(text = "Profile") },
selected = false,
onClick = { /*TODO*/ },
alwaysShowLabel = true,
selectedContentColor = Color.Black,
unselectedContentColor = Color.Gray,
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment