Context selector dropdown component for dashboard navigation.
Allows users with multiple contexts (organizations, farms, teams, etc.) to switch between them. Only renders when the user has 2+ contexts.
Components
context_selector/1- Header dropdown (forposition: :headerwithsub_position: :startor:end)sidebar_context_selector/1- Sidebar dropdown (forposition: :sidebar)mobile_context_selector/1- Mobile menu variant
Usage
Header position (default):
<.context_selector
contexts={@dashboard_contexts}
current={@current_context}
config={@context_selector_config}
/>Sidebar position:
<.sidebar_context_selector
contexts={@dashboard_contexts}
current={@current_context}
config={@context_selector_config}
/>Or use the convenience wrappers that check visibility:
<.context_selector_if_enabled
show={@show_context_selector}
contexts={@dashboard_contexts}
current={@current_context}
config={@context_selector_config}
/>
<.sidebar_context_selector_if_enabled
show={@show_context_selector}
contexts={@dashboard_contexts}
current={@current_context}
config={@context_selector_config}
/>
Summary
Functions
Renders the context selector dropdown.
Conditionally renders the context selector based on visibility flag.
Renders a mobile-friendly context selector for mobile menus.
Conditionally renders the mobile context selector.
Renders a context selector for the sidebar.
Conditionally renders the sidebar context selector.
Functions
Renders the context selector dropdown.
Only renders if there are contexts to display.
Attributes
contexts- List of context itemscurrent- The currently selected contextconfig- The ContextSelector config structclass- Additional CSS classes
Attributes
contexts(:list) (required)current(:any) - Defaults tonil.config(:any) (required)class(:string) - Defaults to"".
Conditionally renders the context selector based on visibility flag.
Use this wrapper to avoid checking @show_context_selector manually.
Attributes
show- Boolean flag from@show_context_selector- All other attributes are passed to
context_selector/1
Attributes
show(:boolean) - Defaults tofalse.contexts(:list) (required)current(:any) - Defaults tonil.config(:any) (required)class(:string) - Defaults to"".
Renders a mobile-friendly context selector for mobile menus.
Shows as a list section at the top of mobile navigation.
Attributes
contexts- List of context itemscurrent- The currently selected contextconfig- The ContextSelector config struct
Attributes
contexts(:list) (required)current(:any) - Defaults tonil.config(:any) (required)
Conditionally renders the mobile context selector.
Attributes
show(:boolean) - Defaults tofalse.contexts(:list) (required)current(:any) - Defaults tonil.config(:any) (required)
Renders a context selector for the sidebar.
Displays as a dropdown at the top of the sidebar navigation.
Attributes
contexts- List of context itemscurrent- The currently selected contextconfig- The ContextSelector config structclass- Additional CSS classes
Attributes
contexts(:list) (required)current(:any) - Defaults tonil.config(:any) (required)class(:string) - Defaults to"".
Conditionally renders the sidebar context selector.
Attributes
show(:boolean) - Defaults tofalse.contexts(:list) (required)current(:any) - Defaults tonil.config(:any) (required)class(:string) - Defaults to"".