Trigger app UI
Run application logic such as opening a chat or modal from the account menu.
Clerk · Component
UserButton.Action adds a custom action item to Clerk's UserButton menu. It can run an onClick callback or open a specific page in the UserProfile modal.
UserButton.Action adds a custom item to the UserButton menu. Give it a label, optionally an icon, and either an onClick handler for application behavior or an open value to open a specific custom page in the UserProfile modal.
<UserButton.Action label="..." labelIcon={...} onClick={...} open="..." />| Name | Type | Description |
|---|---|---|
label | string | The text displayed for the menu item. |
labelIcon | React.ReactElement | An icon displayed beside the label. |
onClick? | void | A callback invoked when the item is clicked. |
open? | string | The path segment used to open a specific UserProfile modal page. |
import { UserButton } from '@clerk/nextjs'
export function AccountMenu() {
return (
<UserButton>
<UserButton.MenuItems>
<UserButton.Action
label="Open chat"
onClick={() => window.alert('Chat opened')}
/>
</UserButton.MenuItems>
</UserButton>
)
}Adds an Open chat item to the user menu and runs application code when the item is clicked.
Run application logic such as opening a chat or modal from the account menu.
Direct users to a configured custom page inside Clerk's profile modal.
Give a custom menu command a recognizable visual marker.
Place UserButton.Action inside UserButton.MenuItems nested within UserButton. The label supplies the menu text, while onClick runs when the user selects the item.
Follow-up: How would you open a profile page instead of running client logic? Set open to the path segment for the custom UserProfile page.
Use labelIcon to render an icon beside the menu label. The icon is a React.ReactElement, so it belongs alongside label in the action's props.
Follow-up: What should be used when the menu item needs navigation to a custom profile page? Use open rather than labelIcon or onClick.
Set open to the path segment of a custom page when the action should open that page in the UserProfile modal. The page must correspond to a configured custom profile page.
Follow-up: What alternative handles a chat modal or other app-owned UI? Supply onClick and trigger that UI from the handler.
UserButtonUserButton.MenuItemsUserButton.LinkUserProfile