UI

User menu

Account menu behind the signed-in user's avatar, with optional presence status, theme switch, and sign out.

import { UserMenu } from '@uthereal/ui/user-menu'

User menu playground

Loading interactive preview…

Overview

UserMenu renders the signed-in account control in an application header. It pairs a 40px avatar trigger with a 15.5rem account panel containing an identity header, up to six account links, an optional presence status switch, an inline light/dark/system theme switch, and a sign-out action. Below 640px, the menu opens as a swipe-dismissible bottom sheet.

Use UserMenu for signed-in identity, appearance preferences, and sign out. For general command menus, use Dropdown menu.

Usage

'use client'
import { UserMenu } from '@uthereal/ui/user-menu'
import type { ColorScheme } from '@uthereal/ui/user-menu'

export function AccountMenu({
  user,
  onSignOut,
  onThemeChange,
}: {
  user: { name: string; email: string; avatarUrl?: string }
  onSignOut: () => void
  onThemeChange: (scheme: ColorScheme) => void
}) {
  return (
    <UserMenu
      name={user.name}
      email={user.email}
      src={user.avatarUrl}
      items={[
        { id: 'profile', label: 'Profile', action: 'open_profile' },
        {
          id: 'settings',
          label: 'Account settings',
          action: 'open_settings',
          shortcut: '⌘,',
        },
      ]}
      signOutAction="sign_out"
      onAction={(action) => {
        if (action === 'sign_out') onSignOut()
      }}
      onColorSchemeChange={onThemeChange}
    />
  )
}

onAction(action, itemId) fires for account items and sign out (user-menu-sign-out). onColorSchemeChange(colorScheme) fires when the user picks a theme; applying the chosen theme to the application belongs to the host.

Examples

Triggers and signing-out state

The default trigger renders a 32px avatar inside a 40px pill, falling back to initials until src loads. Enable showName to display the name and chevron on viewports 640px and wider. Set status to show a shape-coded presence dot, and set signingOut while an async sign-out request is in flight.

Presence, theme, and async sign out

Setting status adds a presence mark to the avatar and inserts an inline Status switch (online, busy, away) inside the panel. Each status uses a distinct shape so availability never depends on color alone:

StatusShapeDefault labelOffered in Status switch
onlineSolidAvailableYes
busyBarredBusyYes
awayHollowAwayYes
offlineHollowOfflineNo

Choosing a status calls onStatusChange(status) and keeps the menu open; pass the updated status back to persist it.

When showColorScheme is true (default), an inline Theme switch offers Light, Dark, and System segments under a sliding thumb. Selecting a segment keeps the menu open and calls onColorSchemeChange(colorScheme).

Sign out always renders as the last row and calls onAction(signOutAction, 'user-menu-sign-out'). For asynchronous sign out, set signingOut={true} from your handler: the menu remains open, displays a spinner and labels.signingOut with aria-busy="true", and closes automatically when signingOut returns to false.

The desktop panel aligns via align ('end' default), opens 8px below (or above if constrained), and stays 12px inside viewport edges. Below 640px, it opens as a bottom sheet over a scrim with scroll locking and closes on a downward drag past 80px or a fast flick.

API reference

These serializable arguments and defaults come directly from the component schema.

ArgumentType / defaultDescription
nameRequiredstring—Required. The signed-in person's name: the avatar's initials and the trigger's accessible name.
srcstring—Picture URL for the avatar; initials show until it loads or if it fails.
emailstring—Email shown under the name in the menu header.
planstring—A small chip beside the name in the menu header, e.g. the plan ("Pro") or role.
statusonline | offline | busy | away—Presence status: online (Available), busy, away or offline. It adds Arc's dot to the avatar (solid, barred or hollow) and an inline Status switch of Available, Busy and Away that keeps the menu open and calls onStatusChange. Omit it for neither.
itemsUserMenuItem[]Default: []Account destinations, at most six (Arc keeps three or four): each with a unique id, a label, an optional icon, a host-registered action and an optional shortcut hint shown one key cap per key.
showColorSchemebooleanDefault: trueOffer the inline Theme switch (Light, Dark, System, as sun, moon and monitor segments with a sliding thumb). Choosing keeps the menu open; applying the theme to the page is the host.
defaultColorSchemelight | dark | systemDefault: "system"The initial theme choice. Later edits do not reset an existing instance; in a composition the stored choice wins.
signOutActionstringDefault: "sign_out"Host-registered action of the Sign out item, always the last row, neutral like the others as in Arc (sign_out by default).
signOutShortcutstring—Key hint of the Sign out row, e.g. "⇧⌘Q".
signingOutbooleanDefault: falseSet by the host while it signs the person out: the menu stays open, Sign out shows a spinner and its label rises to labels.signingOut, and the menu closes when it is cleared.
showNamebooleanDefault: falseShow the name beside the avatar, with a chevron, inside the 40px pill. Below 640px only the avatar shows.
alignstart | center | endDefault: "end"Alignment of the menu against the trigger: start, center or end. It opens 8px below, or above when there is no room, and keeps 12px from the viewport edges.
defaultOpenbooleanDefault: falseStart with the menu open, without moving focus into it. Later edits do not reset an existing instance.
labelsUserMenuLabels—Text: the trigger name (Account menu, {name}; with a status, Account menu, {name}, {status}), the Status switch and status names, the Theme switch and its Light, Dark and System choices, and Sign out and Signing out.
recipestudio | softDefault: "studio"Visual treatment. Both recipes use the same interaction behavior.
themeUserMenuTheme—Color mode and accent, and tokens for the trigger and panel colors, type, status colors and the sheet radius. See Theming.
motionnone | subtle | expressiveDefault: "subtle"Panel, rows, highlight and trigger animation preset. System reduced-motion preferences take precedence (a short fade).
dirltr | rtl—Reading direction. Omit it to inherit the page direction.

Each UserMenuItem accepts { id, label, icon?, action, shortcut? }. IDs listed in userMenuItemIds (user-menu-status, user-menu-color-scheme, user-menu-light, user-menu-dark, user-menu-system, user-menu-sign-out) are reserved.

React integration

PropPurpose
onAction(action, itemId)Called with an item's action or signOutAction ('user-menu-sign-out').
colorScheme, onColorSchemeChangeControl the theme choice ('light' | 'dark' | 'system'). Fires in both modes.
onStatusChange(status)Called when the user selects a presence status in the Status switch.
open, onOpenChangeControl menu visibility.
portalContainerCustom portal mount target; defaults to the enclosing layer, provider, or body.
presetApplication defaults, overridden by explicit instance arguments.
tokensCSS variables applied after the typed theme, forwarded to the portaled panel.
ref, className, styleApplied to the root <span> element.
Native attributesid, aria-*, data-*, and remaining <span> props forwarded to the root.

Standalone PresenceDot

@uthereal/ui/user-menu also exports PresenceDot and PresenceDotProps for rendering the same shape-coded presence indicator on avatars elsewhere in your application. PresenceDot emits its own resolved --ui-* CSS variables and works standalone outside UserMenu.

import { PresenceDot } from '@uthereal/ui/user-menu'

export function MemberBadge() {
  return <PresenceDot status="online" aria-label="Available" />
}
PropTypePurpose
status'online' | 'busy' | 'away' | 'offline'Required. Selects solid, barred, or hollow dot geometry and status color.
recipe'studio' | 'soft'Visual recipe; inherits from UtherealProvider when omitted.
themeUserMenuThemeMode, accent, and semantic token overrides.
motion'subtle' | 'expressive' | 'none'Shape and color transition preset; reduced motion takes precedence.
tokensCssTokensCSS variables applied after the typed theme.
Native attributesComponentPropsWithRef<'span'> (no children)Forwarded to the <span>. Sets aria-hidden="true" unless labelled.

Keyboard & accessibility

KeyInteraction
Enter, SpaceOn trigger: open at the first row. On a menu row: activate it.
ArrowDown, ArrowUpOn trigger: open at first or last row. Inside menu: move focus, wrapping.
Home, EndMove focus to the first or last row in the menu.
LettersTypeahead jump to the next row starting with the typed characters.
ArrowLeft, ArrowRightInside Status or Theme switch: select the previous or next radio option.
Escape, TabClose the menu and return focus to the trigger.

The trigger is a <button> with aria-haspopup="menu", aria-expanded, and an accessible name built from labels.trigger or labels.triggerStatus. Avatars and shortcut caps are hidden from assistive technology. The portaled panel uses role="menu" with role="menuitem" rows and role="menuitemradio" groups for the Status and Theme switches. defaultOpen opens the panel without stealing focus. While signingOut is true, the sign-out row sets aria-busy="true". Reading direction follows dir or inherits from the page. Under forced-colors, borders, focus rings, and selection highlights remain visible.

Motion and theming

On desktop, the panel scales from 0.94 out of the avatar center on a critically damped 0.3s spring while fading in, rows stagger 16ms apart, and dismissal fades to 0.97 over 120ms. The row highlight glides on the snappy spring, switch thumbs slide on the spring curve, and the presence dot morphs smoothly between shapes. On phones, the sheet enters on a 0.36s smooth spring and tracks downward drag. prefers-reduced-motion: reduce keeps a short fade, disables drag-to-dismiss, and snaps highlight jumps; motion="none" removes all transitions.

theme accepts a mode, an accent, core and control token groups, plus borderStrong, success, warning, overlay, and popupRadius. An application-wide UtherealProvider supplies defaults.

Composition

In an agent composition, UserMenu is a leaf. Item action values and signOutAction must name registered host actions. The chosen theme is stored as host state at /menus/instance-<id>/colorScheme and reconciled with defaultColorScheme. See Building with agents.

{
  "type": "UserMenu",
  "props": {
    "name": "Ada Lovelace",
    "items": [
      { "id": "profile", "label": "Profile", "action": "open_profile" }
    ],
    "signOutAction": "sign_out"
  },
  "children": []
}

On this page