# OrganizationSwitcher

![The OrganizationSwitcher renders an account switcher interface that lets signed-in users switch between their Personal and Organization accounts.](https://clerk.com/docs/raw/_public/images/ui-components/android-organization-switcher.png){{ style: { maxWidth: '425px' } }}

The `OrganizationSwitcher` renders an account switcher interface that lets signed-in users switch between their Personal and Organization accounts. It displays the Active Organization, or the user's Personal Account when no Organization is selected, and provides built-in native controls for managing the Active Organization, switching accounts, accepting Organization invitations and suggestions, and creating an Organization when permitted.

`OrganizationSwitcher` only renders when a user is signed in and Organizations are enabled for the instance. When Organization selection is required, the Personal Account option is hidden automatically.

`OrganizationSwitcher` renders the Organization or account trigger only. Render [UserButton](https://clerk.com/docs/android/reference/views/user/user-button.md) separately when your layout also needs a profile control.

> When Organization selection is required, [AuthView](https://clerk.com/docs/android/reference/views/authentication/auth-view.md) automatically handles the `choose_organization` session task. Continue rendering `AuthView` while the session has a pending task, then render your signed-in UI once the task is complete.

## Parameters

| Name                                   | Type                                       | Description                                                                                                                                                                                                                                                             |
| -------------------------------------- | ------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| modifier                               | Modifier                                   | A modifier that gets applied to OrganizationSwitcher.                                                                                                                                                                                                                   |
| clerkTheme                             | ClerkTheme?                                | The theme to apply to the OrganizationSwitcher.                                                                                                                                                                                                                         |
| onOrganizationChanged                  | (() -> Unit)?                              | Called after the user successfully switches to an Organization or Personal AccountPersonal Accounts are individual workspaces that allow users to operate independently without belonging to an Organization. Learn more about Personal Accounts..                      |
| hidePersonal                           | Boolean                                    | Whether the Personal AccountPersonal Accounts are individual workspaces that allow users to operate independently without belonging to an Organization. Learn more about Personal Accounts. option should be hidden even when the option is allowed. Defaults to false. |
| OrganizationSwitcherDisplayMode.Normal | OrganizationSwitcherDisplayMode.Compact    | Normal shows the active account avatar, account name, and disclosure chevron. Compact shows only the avatar-sized account trigger. The default base avatar size is 36.dp.                                                                                               |
| onManageOrganization                   | ((OrganizationMembership) -> Unit)?        | Called when the user selects the Manage organization action. When null, the switcher opens the default OrganizationProfileView.                                                                                                                                         |
| onCreateOrganization                   | ((OrganizationCreationDefaults?) -> Unit)? | Called when the user selects the Create organization action. When null, the switcher opens the default Organization creation flow.                                                                                                                                      |
| organizationProfileCustomRows          | List<OrganizationProfileCustomRow>        | Custom rows forwarded to the default OrganizationProfileView opened by the switcher.                                                                                                                                                                                    |
| organizationProfileCustomDestination   | (@Composable (String) -> Unit)?            | Custom destination builder forwarded to the default OrganizationProfileView. The destination receives the tapped row's routeKey.                                                                                                                                        |

## Usage

The following examples show how to use the `OrganizationSwitcher` in your app.

### Basic usage

```kotlin
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.clerk.api.Clerk
import com.clerk.api.session.pendingTaskKey
import com.clerk.ui.auth.AuthView
import com.clerk.ui.organizationswitcher.OrganizationSwitcher

@Composable
fun HomeScreen() {
    val session by Clerk.sessionFlow.collectAsStateWithLifecycle()
    val user by Clerk.userFlow.collectAsStateWithLifecycle()

    if (user != null && session?.pendingTaskKey == null) {
        Column(
            modifier = Modifier
                .fillMaxSize()
                .statusBarsPadding()
                .padding(24.dp),
        ) {
            OrganizationSwitcher()
        }
    } else {
        AuthView()
    }
}
```

### Compact switcher

```kotlin
import androidx.compose.ui.unit.dp
import com.clerk.ui.organizationswitcher.OrganizationSwitcher
import com.clerk.ui.organizationswitcher.OrganizationSwitcherDisplayMode

OrganizationSwitcher(
    displayMode = OrganizationSwitcherDisplayMode.compact(size = 40.dp),
)
```

### Override default flows

```kotlin
OrganizationSwitcher(
    onOrganizationChanged = {
        // Refresh Organization-scoped data.
    },
    onManageOrganization = { membership ->
        // Navigate to your own Organization settings screen.
    },
    onCreateOrganization = { creationDefaults ->
        // Navigate to your own Organization creation flow.
    },
)
```

### Customize the default Organization profile

Custom rows are shown in the switcher's default [OrganizationProfileView](https://clerk.com/docs/android/reference/views/organization/organization-profile-view.md) only when you provide both `organizationProfileCustomRows` and `organizationProfileCustomDestination`.

```kotlin
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Settings
import com.clerk.ui.organizationprofile.custom.OrganizationProfileCustomRow
import com.clerk.ui.organizationprofile.custom.OrganizationProfileCustomRowPlacement
import com.clerk.ui.organizationprofile.custom.OrganizationProfileRow
import com.clerk.ui.organizationprofile.custom.OrganizationProfileRowIcon
import com.clerk.ui.organizationswitcher.OrganizationSwitcher

OrganizationSwitcher(
    organizationProfileCustomRows = listOf(
        OrganizationProfileCustomRow(
            routeKey = "settings",
            title = "Settings",
            icon = OrganizationProfileRowIcon.Vector(Icons.Filled.Settings),
            placement = OrganizationProfileCustomRowPlacement.After(OrganizationProfileRow.Members),
        )
    ),
    organizationProfileCustomDestination = { routeKey ->
        when (routeKey) {
            // Replace this placeholder with the custom view for your Settings row.
            "settings" -> OrganizationSettingsContent()
        }
    },
)
```

---

## Sitemap

[Overview of all docs pages](https://clerk.com/docs/llms.txt)
