UserMenu
The signed-in user’s avatar menu, and an organization switcher for multi-workspace apps.
Status: beta. Category: Auth.
import { UserMenu, OrganizationSwitcher } from '@glyphui/auth/ui'
Exports: UserMenu, OrganizationSwitcher, userMenuStyles.
Notes
- Items with href navigate through your router (GlyphProvider router).
- OrganizationSwitcher takes label and createLabel, so it can say Workspaces or Teams instead of Organizations.
- The Theme submenu sets light, dark or system mode; turn it off with colorMode={false}.
- compact shows only the avatar; the name stays available to screen readers.
- OrganizationSwitcher renders nothing unless the adapter supports organizations and the user has one.
UserMenu props
| Prop | Type | Default | Description |
|---|---|---|---|
align | "center" | "start" | "end" | ||
className | string | ||
colorMode | boolean | Adds a Theme submenu (light, dark, system). Default true. | |
compact | boolean | Avatar only, with the name and email kept for screen readers. | |
items | readonly UserMenuItem[] | Links such as Profile and Settings, above Sign out. | |
onSignOut | (() => void) | Called after signing out, e.g. to navigate to the landing page. | |
side | "left" | "right" | "top" | "bottom" | Which side the menu opens on. Default bottom; use top in a sidebar footer. |
Example: In a sidebar
OrganizationSwitcher at the top, UserMenu at the bottom, opening upward.
import { AuthProvider, useAuth } from '@glyphui/auth'
import { memoryAdapter } from '@glyphui/auth/memory'
import { OrganizationSwitcher, UserMenu } from '@glyphui/auth/ui'
import { Button, Card, toast } from '@glyphui/ui'
import { CreditCard, Settings } from 'lucide-react'
const adapter = memoryAdapter({
latency: 300,
users: [
{
email: '[email protected]',
password: 'pw',
name: 'Ada Lovelace',
organizations: [
{ id: 'engines', name: 'Analytical Engines', role: 'owner' },
{ id: 'difference', name: 'Difference Ltd', role: 'member' },
],
},
],
})
function Panel() {
const { user, signIn } = useAuth()
if (!user)
return (
<Button onClick={() => signIn({ email: '[email protected]', password: 'pw' })}>
Sign in as Ada
</Button>
)
return (
<Card padding="sm" className="flex h-72 w-64 flex-col justify-between">
<OrganizationSwitcher onSwitch={(org) => toast.success(`Switched to ${org.name}`)} />
<UserMenu
side="top"
align="start"
className="w-full"
items={[
{ label: 'Settings', href: '#settings', icon: <Settings /> },
{ label: 'Billing', href: '#billing', icon: <CreditCard /> },
]}
/>
</Card>
)
}
export default function Example() {
return (
<AuthProvider adapter={adapter} syncTabs={false}>
<Panel />
</AuthProvider>
)
}
Live page: https://glyphui.xyz/components/user-menu