Skip to content

User Menu

The account menu behind an avatar: who is signed in and on which plan, a few account rows, theme and status switches, and a sign out that waits for your auth call. A bottom sheet on phones.

On this page
Used for
  • Account menu
  • Sign out control
  • Presence status
  • Theme choice in header

Examples

Installation

npx knowns-ui@latest add user-menu
For Claude Code, Cursor or Codex: installs it and wires the props to your own data.

Props

user
{ name, email?, image?, plan? }
Who is signed in. The photo falls back to initials; plan shows as a small accent badge after the name. Long names and emails are cut with an ellipsis.
items
UserMenuItem[] | UserMenuItem[][]
Account rows: id, label, icon?, shortcut?, href?, target?, disabled?, textValue?. Nested arrays become sections.
onSelect
(item) => void
A row was picked; the menu closes. Link rows navigate as real links.
theme / onThemeChange
"light" | "dark" | "system"
Shows the theme switch. Picking keeps the menu open; Left and Right change it from the keyboard.
status / onStatusChange
"available" | "busy" | "away"
Optional status switch and a presence mark on the avatar. Each status has its own shape, not only a colour.
onSignOut
() => unknown
Shows Sign out. Return a promise to keep the menu open with a spinner and aria-busy until it settles.
badge
ReactNode
A small mark on the avatar's corner (a plan star, a verified tick) on a ring in the background colour, in the trigger and the panel header. Bottom-right, top-right when the presence mark shows. Decorative; name it with badgeLabel.
badgeLabel
string
What the badge means, added to the trigger name: "Account: Noor Haddad, Pro".
signOutLabel
string
Default"Sign out"
Text of the sign out row.
showName
boolean
Defaultfalse
Name and chevron next to the avatar from 640px up.
compact
boolean
Defaultfalse
A 24px avatar in a 32px hit area, the size of the icon buttons beside it in a header.
align
"start" | "end"
Default"end"
Panel edge lined up with the trigger. The panel is 272px and stays 8px inside the viewport.
sheet
"auto" | "never"
Default"auto"
Below 640px the panel opens as a bottom sheet (drag down to close; no drag with reduced motion).
open / onOpenChange
boolean
Controlled open state.
aria-label
string
Default"Account: <name>"
Name of the trigger; the status is added to it.

What it handles

  1. 01Shows an avatar trigger with the name, email and a plan Badge in the panel header, and an accessible name built from the user, badge label and status.
  2. 02Lists account rows from one array or from several arrays that become sections, with links, shortcut hints and disabled rows.
  3. 03Adds a Light, Dark and System switch when you pass onThemeChange, and a Available, Busy and Away switch with a presence dot on the trigger when you pass onStatusChange.
  4. 04Runs a Sign out row from onSignOut, and when it returns a promise keeps the menu open with a Spinner until the promise settles.
  5. 05Opens as a bottom sheet below 640px that you can drag down to close, unless sheet is never, and stays a popover aligned to the end elsewhere.
  6. 06Moves by arrow keys across rows, whole switches and Sign out, switches options with the left and right arrows, and matches typed text to row labels.

States

First render
Nothing. The panel is closed
none
Popover open
The panel fades in under the avatar
120ms, opacity only
Sheet open
The sheet rises from the bottom edge while the backdrop fades in
280ms, ease out
Switch change
The thumb behind the chosen theme or status slides across
120ms, ease out
Signing out
A Spinner replaces the label and the status is announced; the menu stays open
none
Sheet drag
The sheet follows the pointer with no transition, and closes past a distance or speed
none
Reduced motion
The sheet appears in place and the drag handle is hidden
0ms

Works with

When to use

When to use

  • The signed-in account in an app header: identity, plan, account pages, theme and sign out in one place.

When not to use

  • General actions behind a button: use Menu.
  • Search across the whole app: use Command Menu.

Using with AI

Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:

  • Add the Knowns UI User Menu to my app and wire it to my own data.
  • I need the signed-in account in an app header: identity, plan, account pages, theme and sign out in one place. Set that up with the Knowns UI User Menu.
  • Which User Menu props do I need for a minimal setup? Show me a short example.

With the server connected, your assistant calls get_component({ name: "user-menu" }) and search_docs({ query: "user menu" }).

Need help?

Stuck on User Menu, or found something off? We read every message.