SutraUI.TabNav (Sutra UI v0.2.0)
View SourceVisual tab navigation component for server-side routed tabs.
Unlike the full tabs component which manages content panels client-side,
this component only provides the visual tab navigation. Each tab links to
a different LiveView route, allowing heavy content (analytics, tables, etc.)
to load only when active.
Features
- Visual-only tab navigation (no content panel management)
- Server-side routing via LiveView patches
- Full keyboard navigation (arrow keys, Home, End)
- Icon support via inner block
- Consistent styling across pages
- Permission-aware rendering (slots can be conditionally rendered)
Examples
<.tab_nav id="org-tabs">
<:tab patch={~p"/orgs/#{@org.id}"} active={@active_tab == :show}>
About
</:tab>
<:tab patch={~p"/orgs/#{@org.id}/members"} active={@active_tab == :members}>
Members
</:tab>
</.tab_nav>Permission-aware usage
<.tab_nav id="batch-tabs">
<:tab patch={~p"/batches/#{@batch.id}"} active={@active_tab == :overview}>
Overview
</:tab>
<%= if @can_manage do %>
<:tab patch={~p"/batches/#{@batch.id}/settings"} active={@active_tab == :settings}>
Settings
</:tab>
<% end %>
</.tab_nav>Keyboard Navigation
| Key | Action |
|---|---|
ArrowLeft | Move to previous tab |
ArrowRight | Move to next tab |
Home | Move to first tab |
End | Move to last tab |
Enter / Space | Navigate to focused tab |
Accessibility
- Uses
role="tablist"for the container - Uses
role="tab"for each tab trigger aria-selectedindicates active tabtabindexmanagement for roving focus- Active tab marked with
aria-selected="true"
Summary
Functions
Renders a visual tab navigation bar.