NavigationBar com Várias Abas
Alterne entre seções principais na parte inferior.
NavigationBar com Várias Abas é uma aula grátis de Jetpack Compose Academy no CoddyKit. Esta é a aula 1 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de Jetpack Compose Academy, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de Jetpack Compose Academy inclui 4 aulas no total.
Partes desta aula ainda não foram traduzidas e aparecem em inglês.
Meet NavigationBar
Material 3 gives you NavigationBar, a bar pinned to the bottom that lets people jump between the top-level sections of your app. 📱
When to Use It
Reach for a NavigationBar when your app has three to five equally important destinations, like Home, Search, and Profile.
It Lives in the Scaffold
You usually drop the bar into a Scaffold bottomBar slot, so it stays fixed while the screen content scrolls above it.
Scaffold(
bottomBar = { NavigationBar { /* items */ } }
) { padding -> Content(padding) }Each Tab Is an Item
Inside the bar you add one NavigationBarItem per destination. Each item is a clickable tab with its own icon and label.
NavigationBar {
NavigationBarItem(/* ... */)
NavigationBarItem(/* ... */)
}The selected Flag
Every item needs a selected boolean. Exactly one item should be true at a time so the bar shows where the user is.
NavigationBarItem(
selected = current == "home",
onClick = { go("home") }
)Handle the Tap
The onClick lambda runs when the tab is pressed. This is where you tell your navigation to switch to that section.
Give It an Icon
The icon slot takes a Composable, usually an Icon from the Material set, so each tab is instantly recognizable.
icon = { Icon(Icons.Default.Home, contentDescription = "Home") }Add a Label
The label slot shows short text under the icon. Keep it to one clear word so it fits and reads fast.
label = { Text("Home") }A Model for Tabs
It helps to keep your tabs in a simple data class list, so the bar can loop over them instead of hard-coding each item.
data class Tab(val route: String, val icon: ImageVector, val label: String)Loop to Build the Bar
With a tab list you can forEach over it and emit one NavigationBarItem per entry, keeping the bar tidy and easy to extend.
tabs.forEach { tab ->
NavigationBarItem(/* uses tab fields */)
}Pair It with Content
The bar only switches the active section. You still pair it with a NavHost or a when block that actually swaps the screen content.
Quick Check
You added three tabs to your NavigationBar. Quick check on the basics.
Recap
You met NavigationBar: drop it in the Scaffold, add a NavigationBarItem per section with an icon, label, selected flag, and onClick. Nice work! 🎉
Perguntas Frequentes
A aula “NavigationBar com Várias Abas” é grátis?
Sim — o texto completo de “NavigationBar com Várias Abas” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de Jetpack Compose Academy, atualize para CoddyKit PRO. O curso de Jetpack Compose Academy inclui 4 aulas no total.
O que vou aprender em “NavigationBar com Várias Abas”?
Alterne entre seções principais na parte inferior. Você pratica Jetpack Compose Academy com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.
Preciso ter experiência prévia para começar Jetpack Compose Academy?
Nenhuma experiência prévia é necessária. Jetpack Compose Academy no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 1 de 4.
Quanto tempo leva a aula “NavigationBar com Várias Abas”?
A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.
Posso escrever e executar código nesta aula de Jetpack Compose Academy?
Sim. Cada aula de Jetpack Compose Academy inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.
Todas as aulas deste curso
- NavigationBar com Várias Abas
- Destacando a Rota Selecionada
- Preservando o Estado das Abas ao Alternar
- TabRow e Páginas Deslizáveis