Skip to main content

<OrganizationSwitcher />

The OrganizationSwitcher component of the WSO2 Identity Server Vue SDK (@asgardeo/vue) renders a dropdown that lets the user switch between the organizations they belong to.

Overview​

The button shows the name of the current organization. Opening it lists the user's organizations and marks the current one. When the user picks an organization, the SDK switches to it with an organization_switch token exchange, then reloads the user, the profile and the organizations.

Usage​

The following examples show how to use OrganizationSwitcher.

Basic usage​

OrganizationSwitcher example
<script setup>
import { OrganizationSwitcher, SignedIn } from '@asgardeo/vue'
</script>

<template>
<SignedIn>
<OrganizationSwitcher />
</SignedIn>
</template>

Custom UI​

Use the default slot to render your own switcher.

Custom switcher
<template>
<OrganizationSwitcher
v-slot="{ currentOrganization, organizations, isOpen, toggle, handleSelect }"
>
<button @click="toggle">{{ currentOrganization?.name ?? 'Select organization' }}</button>
<ul v-if="isOpen">
<li v-for="org in organizations" :key="org.id">
<button @click="handleSelect(org)">{{ org.name }}</button>
</li>
</ul>
</OrganizationSwitcher>
</template>

Props​

PropTypeRequiredDescription
classNamestring❌CSS class to add to the root element.

Slots​

The default slot replaces the built-in UI and receives the following slot props:

Slot propTypeDescription
currentOrganizationOrganization or nullThe organization the user is signed in to.
organizationsOrganization[]The user's organizations.
isLoadingbooleanWhether a switch is in progress.
isOpenbooleanWhether the dropdown is open.
toggle() => voidOpens or closes the dropdown.
handleSelect(organization: Organization) => voidCloses the dropdown and switches to the organization.

Was this page helpful?