Phase 1: Mobile Fundamentals

Navigation patterns: tabs, stacks, drawers & modals

Beginner ~3 min read
Think of it this way A friendly analogy. Read this if the technical version feels dense. Show Hide

Imagine playing your favorite board game on a tablet or phone! Just like a real board game has different parts and rules for how you move, apps on your phone also need clear ways for you to navigate around and find what you’re looking for.

Think of tabs like the main sections of your game board that are always visible. Maybe at the bottom of the screen, you see labels like "Map," "Inventory," or "Leaderboard." These are the core parts of your game, always ready for you to tap and jump between. They help you quickly switch between seeing where you are, checking your cool items, or finding out who’s winning, without ever getting lost.

Now, let's say you're on the "Inventory" tab, looking at a list of your magic swords. If you tap on one specific sword to read about its special powers, a new, detailed card about just that sword slides right on top of your "Inventory" screen. This is like a stack. You've gone deeper into the game to see more details about one item. To go back to your full list of swords, you just tap a "back" arrow, and that sword card slides away, revealing the "Inventory" screen again. It’s like putting cards on top of each other and then removing them one by one.

Sometimes you need to do things that aren't part of the main game, like changing settings or reading the rulebook. For these, imagine a secret compartment that slides out from the side of your game box. When you need it, you swipe your finger, and a panel appears with options like "Game Rules," "Settings," or "Invite Friends." This is a drawer. It keeps your main game screen neat and tidy, but you can still access important extra features when you need them. And what if something super important happens that demands your full attention, like a "Level Up!" message or a question you have to answer, like "Do you want to use your potion?" A big message or question will pop up right in the middle of your screen, covering everything else until you deal with it. This is a modal, like a special "event card" that takes over the whole board until you make a choice.

So, when you start to build your own apps, thinking about these different ways to guide players around your game (or users around your app) helps you make it easy and fun for them to use. You're like the game designer, deciding the best way for players to move around and interact with all the cool stuff you create.

When building mobile apps, how users move between different parts of your application is crucial. Tabs are a common pattern for primary navigation, showing peer-level sections that users switch between frequently, like "Home," "Search," or "Profile." They're always visible at the top or bottom of the screen, making core app functionality easily accessible. For drilling down into content, like viewing details of an item from a list, we use Stacks. Imagine a stack of cards: when you tap an item, a new screen (card) pushes on top, and a "back" button removes it, revealing the previous screen. This creates a clear hierarchical flow.

Sometimes you need to offer navigation options that aren't always visible, or temporary interactions. Drawers (often called "hamburger menus") are ideal for secondary navigation, like "Settings," "Help," or "About Us." They slide out from the side of the screen when activated, keeping the main screen clear. For focused, temporary interactions, Modals pop up, overlaying the current screen. They usually demand user attention, such as a login form, a confirmation dialog ("Are you sure?"), or displaying a large image. Modals typically require an explicit action to dismiss, ensuring the user completes a task or acknowledges information before returning to the main flow.

Effective mobile apps often combine these patterns. For instance, an app might use tabs for its main sections, and within each tab, use a stack to navigate deeper into content. A drawer could house less-frequent options, and modals could handle specific actions like adding a new item or confirming a deletion. Understanding when to apply each pattern helps create an intuitive and efficient user experience, making your app easier and more enjoyable to use.

Key Takeaways

  • Tabs: Best for primary, frequently accessed, peer-level app sections.
  • Stacks: Ideal for hierarchical navigation, drilling into details with a clear back path.
  • Drawers: Suited for secondary, less frequently accessed options, hidden until needed.
  • Modals: Used for temporary, focused tasks or critical information that requires immediate user attention.

Code Example

javascript
Preview

How this code works

This code demonstrates how to navigate between different screens in a mobile application using a "stack" metaphor, much like stacking plates. The viewItemDetails function handles moving from a general list screen to a more specific screen showing an item's details. It achieves this by calling navigation.push('DetailsScreen', { id: itemId }). The navigation.push() command adds a new screen, named 'DetailsScreen', to the top of the stack. It also passes along relevant data, like the itemId, so the new screen knows which item to display. Crucially, the previous list screen remains active but hidden underneath this new details screen, ready for when a user wants to go back.

To return to the previous screen, the goBackToList function is used. This function calls navigation.pop(). The navigation.pop() command removes the current screen from the very top of the navigation stack, much like taking the top plate off a stack. This action automatically reveals the screen that was directly underneath it. A subtle but important point for beginners is that navigation.pop() doesn't require any arguments because it always targets and removes only the currently displayed screen, effectively reversing the last push operation.