0PricingLogin
Jetpack Compose Academy · Lesson

Highlighting the Selected Route

Sync selection with the back stack.

Selection Must Be Real

A tab should light up because of where the user actually is, not a value you set by hand. The back stack is your source of truth. 🧭

Read the Current Entry

Ask the NavController for the live currentBackStackEntryAsState. It updates automatically every time navigation changes.

val entry by navController.currentBackStackEntryAsState()

All lessons in this course

  1. NavigationBar with Multiple Tabs
  2. Highlighting the Selected Route
  3. Preserving Tab State on Switch
  4. TabRow & Swipeable Pages
← Back to Jetpack Compose Academy