<UserButton />

The <StackUserButton> renders a user button component with optional user information, color mode toggle, and extra menu items.

Component Demo

Interactive Demo

Try out the UserButton component with different props and see the changes in real-time:

Component Options

Whether to display user information (display name and email) or only show the avatar.

Function to be called when the color mode toggle button is clicked. If specified, a color mode toggle button will be shown.

Additional menu items to display in the dropdown.

Live Preview

Component Demo

Code Example

Props

PropTypeDefaultDescription
showUserInfooptional
booleanfalseIf true, displays user information (display name and email) in the button.
colorModeToggleoptional
() => void | Promise<void>undefinedFunction to be called when the color mode toggle button is clicked. If specified, a color mode toggle button will be shown.
extraItemsoptional
ArrayAdditional menu items to display. Each item should have the following properties:
text
stringThe text to display for the item.
icon
React.ReactNodeThe icon to display for the item.
onClick
() => void | Promise<void>Function to be called when the item is clicked.

Example

'use client';
import { UserButton } from '@stackframe/stack';

export default function Page() {
  return (
    <div>
      <h1>User Button</h1>
      <UserButton
        showUserInfo={true}
        colorModeToggle={() => { console.log("color mode toggle clicked") }}
        extraItems={[{
          text: 'Custom Action',
          icon: <CustomIcon />,
          onClick: () => console.log('Custom action clicked')
        }]}
      />
    </div>
  );
}

Table of Contents

Navigate this page

Stack Auth AI

Documentation assistant

Experimental: AI responses may not always be accurate—please verify important details.

For the most accurate information, please join our Discord or email us.

How can I help?

Ask me about Stack Auth while you browse the docs.