Tab Nav

Visual tab navigation component for server-side routed tabs.

Unlike the full tabs component which manages content panels client-side, Tab Nav only provides the visual tab navigation. Each tab links to a different LiveView route, allowing heavy content to load only when active.

Default

Usage

Tab Nav uses patch for LiveView navigation, keeping the socket connection alive.

Usage
# In your LiveView
def mount(%{"id" => id}, _session, socket) do
  {:ok, assign(socket, org: get_org(id), active_tab: :about)}
end

# In the template
<.tab_nav>
  <:tab patch={~p"/orgs/#{@org.id}"} active={@active_tab == :about}>
    About
  </:tab>
  <:tab patch={~p"/orgs/#{@org.id}/members"} active={@active_tab == :members}>
    Members
  </:tab>
</.tab_nav>

With Icons

Include icons alongside text in the tab inner block.

With Icons

When to Use

Tab Nav is ideal for scenarios where:

  • Each tab loads different data from the server
  • Tab content is heavy (analytics, tables, charts)
  • You want separate URLs for each tab for bookmarking
  • Content should only load when the tab is active

For client-side tab switching with all content loaded upfront, use the Tabs component instead.

Accessibility

Tab Nav provides visual tab styling. For full keyboard navigation and ARIA support, use the Tabs component.