Skip to main content

<OrganizationSwitcher>

The <OrganizationSwitcher> component is used to switch between organizations the user is a member of in your application.

Usage

import { OrganizationSwitcher } from "@slashid/react"

export default function Home() {
return <OrganizationSwitcher />
}

By default all of the users organizations and suborganizations will be shown regardless of any suborganization tree hierarchy. For greater control see the filter prop.

With filtering

import { OrganizationSwitcher } from "@slashid/react"

// hide any org prefixed with "private_"
export default function Home() {
return (
<OrganizationSwitcher
filter={(org) => !org.org_name.startsWith("private_")}
/>
)
}

With rendered organization name overriding

import { OrganizationSwitcher } from "@slashid/react"

// renders "ORG_NAME (TENANT_NAME)"
export default function Home() {
return (
<OrganizationSwitcher
renderLabel={(org) => `${org.name} (${org.tenant_name})`}
/>
)
}

Props

nametypedefaultdescription
fallback?React.ReactNode<Dropdown disabled />The content shown while organizations are being fetched
filter?(organization: OrganizationDetails) => booleanA predicate function to filter the available organizations
renderLabel?(organization: OrganizationDetails) => string(org) => org.org_nameA render function called for each item in the menu

Interface: OrganizationDetails

interface OrganizationDetails {
id: string;
org_name: string;
tenant_name: string;
managed_organizations?: Organization[];
}
PropertyTypeDescription
idstringThe organizations id
org_namestringThe organizations name
tenant_namestringThe name of the tenant of this organization
managed_organizations?Organization[]A list of child organizations