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.
Used for
- Account menu
- Sign out control
- Presence status
- Theme choice in header
Examples
Installation
npx knowns-ui@latest add user-menuFor Claude Code, Cursor or Codex: installs it and wires the props to your own data.
Paste this into your coding agent (Claude Code, Cursor, Codex). It checks your project, sets up the registry, runs the install and verifies it.
Install prompt
Install User menu from Knowns UI into this project. Work step by step, show me each change, and ask before you edit files outside this project.
Context: Knowns UI (https://ui.knowns.dev) is a shadcn registry. Items land in the project as source files. Docs: https://ui.knowns.dev/docs/user-menu
1. Check the project first. Stop and tell me if any of these is missing:
- React 19 and Tailwind CSS v4.
- A components.json at the project root. If there is none, ask me before running `npx knowns-ui@latest init --no-key` (it runs shadcn init when needed, then adds the registries).
2. Run:
```bash
npx knowns-ui@latest add user-menu
```
It writes these files:
- lib/knowns/run.ts
- lib/knowns/json.tsx
- lib/knowns/status.ts
- lib/knowns/tone.ts
- lib/knowns/types.ts
- lib/knowns/use-abortable.ts
- lib/knowns/utils.ts
- lib/knowns/motion.tsx
- lib/knowns/motion-utils.ts
- components/ui/knowns/use-floating.ts
- components/ui/knowns/tooltip.tsx
- components/ui/knowns/tooltip-utils.ts
- components/ui/knowns/avatar.tsx
- components/ui/knowns/badge.tsx
- components/ui/knowns/menu.tsx
- components/ui/knowns/spinner.tsx
- components/ui/knowns/user-menu.tsx
and installs these npm packages: clsx@^2.1.1, tailwind-merge@^3.7.0.
3. While it runs:
- It also adds a few @keyframes (all named kn-*) to the global CSS file (globals.css or the file components.json points at). Let it: they only add animations.
- If it asks to overwrite files under lib/knowns/: these are shared by every Knowns UI item. List them, say whether I changed them (check git), and ask me before you answer.
- If it asks to overwrite any other file, show me the diff and ask me.
4. Verify:
- Every file in the list above exists.
- The project type-checks (for example `npx tsc --noEmit`) and the dev build has no new errors.
5. Use it: follow the examples and props on https://ui.knowns.dev/docs/user-menu, and ask me if anything about my data is unclear.
If the Knowns UI MCP server is connected (https://ui.knowns.dev/docs/ai-and-mcp), use get_component({ name: "user-menu" }) or search_docs for details.
Finish with a short summary: the files you added or changed, the packages you installed, and anything I still need to do.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- Default
false - Name and chevron next to the avatar from 640px up.
- compact
boolean- Default
false - 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.
| Prop | Type | Default | Description |
|---|---|---|---|
| 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 | "Sign out" | Text of the sign out row. |
| showName | boolean | false | Name and chevron next to the avatar from 640px up. |
| compact | boolean | false | A 24px avatar in a 32px hit area, the size of the icon buttons beside it in a header. |
| align | "start" | "end" | "end" | Panel edge lined up with the trigger. The panel is 272px and stays 8px inside the viewport. |
| sheet | "auto" | "never" | "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 | "Account: <name>" | Name of the trigger; the status is added to it. |
What it handles
- 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.
- 02Lists account rows from one array or from several arrays that become sections, with links, shortcut hints and disabled rows.
- 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.
- 04Runs a Sign out row from onSignOut, and when it returns a promise keeps the menu open with a Spinner until the promise settles.
- 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.
- 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
| State | What moves | Timing |
|---|---|---|
| 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
- AvatarInstalled with it. The trigger and header show the person with the status ring and an optional badge.
- MenuInstalled with it. Row highlight and typeahead matching come from Menu.
- SpinnerInstalled with it. It marks the Sign out row while onSignOut is pending.
- Theme togglePairs with it: use the icon toggle in a toolbar and this switch inside the account panel.
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" }).