# `PhoenixKitWeb.Components.Dashboard.ContextSelector`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.165/lib/phoenix_kit_web/components/dashboard/context_selector.ex#L1)

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 (for `position: :header` with `sub_position: :start` or `:end`)
- `sidebar_context_selector/1` - Sidebar dropdown (for `position: :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}
    />

# `context_selector`

Renders the context selector dropdown.

Only renders if there are contexts to display.

## Attributes

- `contexts` - List of context items
- `current` - The currently selected context
- `config` - The ContextSelector config struct
- `class` - Additional CSS classes

## Attributes

* `contexts` (`:list`) (required)
* `current` (`:any`) - Defaults to `nil`.
* `config` (`:any`) (required)
* `class` (`:string`) - Defaults to `""`.

# `context_selector_if_enabled`

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 to `false`.
* `contexts` (`:list`) (required)
* `current` (`:any`) - Defaults to `nil`.
* `config` (`:any`) (required)
* `class` (`:string`) - Defaults to `""`.

# `mobile_context_selector`

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 items
- `current` - The currently selected context
- `config` - The ContextSelector config struct

## Attributes

* `contexts` (`:list`) (required)
* `current` (`:any`) - Defaults to `nil`.
* `config` (`:any`) (required)

# `mobile_context_selector_if_enabled`

Conditionally renders the mobile context selector.

## Attributes

* `show` (`:boolean`) - Defaults to `false`.
* `contexts` (`:list`) (required)
* `current` (`:any`) - Defaults to `nil`.
* `config` (`:any`) (required)

# `sidebar_context_selector`

Renders a context selector for the sidebar.

Displays as a dropdown at the top of the sidebar navigation.

## Attributes

- `contexts` - List of context items
- `current` - The currently selected context
- `config` - The ContextSelector config struct
- `class` - Additional CSS classes

## Attributes

* `contexts` (`:list`) (required)
* `current` (`:any`) - Defaults to `nil`.
* `config` (`:any`) (required)
* `class` (`:string`) - Defaults to `""`.

# `sidebar_context_selector_if_enabled`

Conditionally renders the sidebar context selector.

## Attributes

* `show` (`:boolean`) - Defaults to `false`.
* `contexts` (`:list`) (required)
* `current` (`:any`) - Defaults to `nil`.
* `config` (`:any`) (required)
* `class` (`:string`) - Defaults to `""`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
