Skip to main content

<UserDropdown />

You're reading Identity & Access Management 7.2.0. The newest release is 7.3.0, and Cloud has the newest features. Go to the newest release

The UserDropdown component displays a user avatar with a dropdown menu, automatically retrieving user data from the WSO2 Identity Platform authentication context. It includes an inbuilt user profile popup and sign-out functionality, making it easy to integrate profile management and sign-out actions.

Overview​

The UserDropdown component shows a trigger (usually an avatar) that opens a dropdown menu with user-related actions, such as viewing the profile or signing out. The profile dialog appears as a popup, and sign-out is handled internally. You can customize the dropdown and trigger using props or render props.

Usage​

You can use the UserDropdown in several ways: with default behavior, custom menu items, or full render props for advanced UI control.

Basic Usage​

Show a user dropdown with default menu items and user data.

UserDropdown Example
import { UserDropdown } from '@asgardeo/nextjs'

<UserDropdown />

With Custom Menu Items​

You can provide custom menu items for the dropdown menu:

Custom Menu Items
<UserDropdown menuItems={[
{ label: 'Profile', onClick: () => {} },
{ label: 'Settings', href: '/settings' },
{ label: 'Sign Out', onClick: () => {} }
]} />
Note

You can provide a fallback prop to render custom content when no user is signed in.

With Custom Configuration​

Customize the dropdown appearance and fallback content:

Custom Configuration
<UserDropdown
showTriggerLabel={true}
avatarSize={40}
fallback={<div>Please sign in</div>}
/>

Props​

The UserDropdown component accepts all props from BaseUserDropdown, except user and onManageProfile (handled internally):

PropTypeRequiredDescription
menuItemsMenuItem[]❌Custom menu items for the dropdown
showTriggerLabelboolean❌Show user's name next to avatar
avatarSizenumber❌Size of the avatar
fallbackReactElement❌Content to show when no user is signed in
childrenfunction❌Render prop for full customization
renderTriggerfunction❌Custom trigger button renderer

Was this page helpful?