Sidebar component for the user dashboard.
Renders the complete dashboard navigation with:
- Grouped tabs with headers
- Active state highlighting
- Badge indicators
- Presence counts
- Attention animations
- Mobile bottom navigation
- Collapsible groups
- Context selector (when
position: :sidebaris configured)
Usage
<.dashboard_sidebar
current_path={@url_path}
scope={@phoenix_kit_current_scope}
locale={@current_locale}
/>Live Updates
The sidebar automatically updates when tabs change if you subscribe to updates:
def mount(_params, _session, socket) do
if connected?(socket) do
Phoenix.PubSub.subscribe(PhoenixKit.PubSub, PhoenixKit.Dashboard.pubsub_topic())
end
{:ok, socket}
end
def handle_info({:tab_updated, _tab}, socket) do
{:noreply, assign(socket, :tabs, PhoenixKit.Dashboard.get_tabs())}
end
Summary
Functions
Renders the complete dashboard sidebar with all tabs.
Renders a floating action button for mobile that opens a tab menu.
Renders a mobile-friendly bottom navigation bar.
Renders a "more" dropdown menu for overflow tabs on mobile.
Renders a group of tabs with optional header.
Renders a tab along with its subtabs (if any).
Renders tabs with a context selector inserted at the appropriate priority position.
Functions
Renders the complete dashboard sidebar with all tabs.
Attributes
current_path- The current URL path for active state detectionscope- The current authentication scope for visibility filteringlocale- The current locale for path generationtabs- Optional pre-loaded tabs (defaults to loading from registry)viewer_counts- Optional map of tab_id => viewer_countcollapsed_groups- Set of collapsed group IDsshow_presence- Show presence indicators (default: true)compact- Render in compact mode (default: false)class- Additional CSS classesshow_context_selector- Show context selector at top of sidebar (default: false)dashboard_contexts- List of available contextscurrent_context- Currently selected contextcontext_selector_config- ContextSelector config struct
Multi-Selector Attributes (optional)
context_selector_configs- List of all ContextSelector configsdashboard_contexts_map- Map of key => list of contextscurrent_contexts_map- Map of key => current contextshow_context_selectors_map- Map of key => boolean
Attributes
current_path(:string) - Defaults to"/dashboard".scope(:any) - Defaults tonil.locale(:string) - Defaults tonil.tabs(:list) - Defaults tonil.viewer_counts(:map) - Defaults to%{}.collapsed_groups(:any) - Defaults toMapSet.new([]).show_presence(:boolean) - Defaults totrue.compact(:boolean) - Defaults tofalse.class(:string) - Defaults to"".show_context_selector(:boolean) - Defaults tofalse.dashboard_contexts(:list) - Defaults to[].current_context(:any) - Defaults tonil.context_selector_config(:any) - Defaults tonil.context_selector_configs(:list) - Defaults to[].dashboard_contexts_map(:map) - Defaults to%{}.current_contexts_map(:map) - Defaults to%{}.show_context_selectors_map(:map) - Defaults to%{}.
Renders a group of tabs with optional header.
Attributes
group(:map) (required)tabs(:list) (required)viewer_counts(:map) - Defaults to%{}.locale(:string) - Defaults tonil.collapsed(:boolean) - Defaults tofalse.compact(:boolean) - Defaults tofalse.
Renders a tab along with its subtabs (if any).
Subtabs are shown based on the parent tab's subtab_display setting:
:when_active- Subtabs only shown when parent is active:always- Subtabs always visible
Attributes
tab(:any) (required)all_tabs(:list) (required)viewer_counts(:map) - Defaults to%{}.locale(:string) - Defaults tonil.compact(:boolean) - Defaults tofalse.
Renders tabs with a context selector inserted at the appropriate priority position.
Attributes
tabs(:list) (required)all_tabs(:list) (required)viewer_counts(:map) - Defaults to%{}.locale(:string) - Defaults tonil.compact(:boolean) - Defaults tofalse.show_context_selector(:boolean) - Defaults tofalse.dashboard_contexts(:list) - Defaults to[].current_context(:any) - Defaults tonil.context_selector_config(:any) - Defaults tonil.