Axon 911 Frontend DocsAxon 911 Frontend Docs
Axon 911 Frontend Docs
    Loading navigation…
U
User
Switch to light mode
  1. Components
  2. User Menu
  3. API and Development

User Menu

API and Development

View SourceOpens in a new tabSubmit IssueOpens in a new tab
Import UserMenu, UserMenuStatus from @prepared911/ui/user-menu.
UserMenu
PropTypeDescription
nameLocalizedMessage | DisplayValueThe person's name: initials source, header title, and the visible name with showName
emailDisplayValueShown under the name, truncated, full text as title
avatarSrcstringPhoto URL. Initials show without it or when it fails
initialsLocalizedMessage | DisplayValueAvatar text with no photo. Defaults to the first letters of the first two words of name
planLocalizedMessagePlan badge beside the name
showNamebooleanDraw the name and a chevron from 640px up. Default false
triggerLabelLocalizedMessage | (status) => LocalizedMessageAccessible name of the avatar trigger; required without trigger. Include the name, and the status when availability is on
triggerReactElementA control that opens the menu in place of the avatar button, such as a preferences icon Button in a top bar. It keeps its own name; UserMenu adds aria-haspopup, aria-expanded, the press and arrow-key handlers and focus return. With it, triggerLabel, showName, disabled, className and ref are not accepted (put them on the control)
itemsreadonly UserMenuItem[]Account destinations
preferencesLabelLocalizedMessageHeading of the preferences group
appearanceLabelsUserMenuAppearanceLabelsPassing it shows the Theme row
appearance / defaultAppearance / onAppearanceChangeAppearanceModeControlled value, initial value (default System), and the report
reduceMotionLabelLocalizedMessagePassing it shows the Reduce motion row
reduceMotion / defaultReduceMotion / onReduceMotionChangebooleanControlled value, initial value (default false), and the report
status / defaultStatus / onStatusChangeUserMenuStatusOptional. Any of them shows the presence dot and availability rows (default Available); with none, nothing renders
statusLabelsUserMenuStatusLabelsRequired with any status prop
signOutLabel, signingOutLabelLocalizedMessageSign out row label, and its label while pending. The row is neutral, not destructive
onSignOut() => void | Promise<void>A promise keeps the menu open on a busy row until it settles
open / defaultOpen / onOpenChangeboolean, (open, details) => voidOpen state
sideSideDefault "block-end"
alignAlignDefault "end"
disabledbooleanInert trigger
classNamestringAppended to the trigger
refRef<HTMLButtonElement>The trigger
UserMenuItem
FieldTypeDescription
idstringUnique among the items
labelLocalizedMessageRow label
iconGlyphLeading icon
shortcutLocalizedMessageOptional. Visual hint at the inline end, hidden from assistive technology. Nothing is drawn without it
disabledbooleanInert row
onSelect() => voidCalled on a press; the menu then closes
Enums
  • AppearanceMode: Light, Dark, System.
  • UserMenuStatus: Available (success dot), Busy (error dot), Away (warning dot).
Props
NameTypeDefaultDescription
nameUserMenuName—The person's name. It is the avatar's initials source and the header title.
onSignOut() => void | Promise<void>—Called when a person presses Sign out. When it returns a promise the row shows a spinner, reads signingOutLabel, is aria-busy, and ignores further presses until the promise settles; then the menu closes. A rejection is left to the app and still closes the menu.
signingOutLabelLocalizedMessage—Label of the sign out row while onSignOut is pending.
signOutLabelLocalizedMessage—Label of the sign out row.
alignAlign"end"Alignment along that edge.
appearanceAppearanceMode—Controlled appearance preference. Pair with onAppearanceChange.
appearanceLabelsUserMenuAppearanceLabels—Names of the appearance choices. Passing it shows the Theme row.
avatarSrcstring—Trusted image URL of the person's photo. Without it, or when it fails to load, the initials show.
classNamestring—Classes appended to the trigger. Put overrides in @layer chroma.overrides.
defaultAppearanceAppearanceModeAppearanceMode.SystemInitial appearance preference when uncontrolled.
defaultOpenbooleanfalseInitial open state when uncontrolled.
defaultReduceMotionbooleanfalseInitial reduce motion preference when uncontrolled.
defaultStatusUserMenuStatusUserMenuStatus.AvailableInitial availability when uncontrolled.
disabledboolean—Disables the trigger.
emailDisplayValue—The person's email. It is truncated in the header and its full text is the title.
initialsUserMenuName—Text shown when there is no photo. Defaults to the first letters of the first two words of name.
itemsreadonly UserMenuItem[]—Account destinations between the header and the preferences.
onAppearanceChangeAppearanceChangeHandler—Called when a person picks an appearance. UserMenu only reports; the app applies it, for example by setting data-theme on <html>. The menu stays open. May be canceled.
onOpenChangeUserMenuOpenChangeHandler—Called on trigger press ("trigger-press"), item press ("item-press"), Tab ("focus-out"), and Escape or an outside press ("light-dismiss", not cancelable).
onReduceMotionChangeReduceMotionChangeHandler—Called when a person flips the switch. UserMenu only reports; the app applies it by setting data-motion="reduced" on <html>. The menu stays open. May be canceled.
onStatusChangeStatusChangeHandler—Called when a person picks an availability. The menu stays open. May be canceled.
openboolean—Controlled open state. Pair with onOpenChange.
planLocalizedMessage—Name of the person's plan, drawn as a badge beside the name in the header.
preferencesLabelLocalizedMessage—Visible heading of the preferences group. Without it the rows sit in the menu with no heading.
reduceMotionboolean—Controlled reduce motion preference. Pair with onReduceMotionChange.
reduceMotionLabelLocalizedMessage—Label of the Reduce motion switch row. Passing it shows the row.
refRef<HTMLButtonElement>—Ref to the trigger button.
showNamebooleanfalseShows the name and a chevron beside the avatar from 640px of viewport width up. Below that only the avatar shows.
sideSide"block-end"Preferred edge of the trigger.
statusUserMenuStatus—Controlled availability. Pair with onStatusChange.
statusLabelsUserMenuStatusLabels—Names of the availability choices.
triggerReactElement<MenuControlChildProps, string | JSXElementConstructor<any>>—A control that opens the menu in place of the avatar button; see {@link UserMenuCustomTriggerProps}. The control that opens the menu, usually a Button. UserMenu adds aria-haspopup="menu", aria-expanded, the press and arrow-key handlers and, on close, returns focus to it; the control's own handlers run first and its ref is kept. Name it with its own label, and set disabled, className and ref on it, not on UserMenu.
triggerLabel((LocalizedMessage | ((status: UserMenuStatus) => LocalizedMessage)) & (LocalizedMessage | ((status: UserMenuStatus | undefined) => LocalizedMessage))) | undefined—Name of the avatar trigger. Required with it; see {@link UserMenuAvatarTriggerProps}. Accessible name of the avatar trigger, such as "Dana Levi, account menu". It includes the person's name and, when availability is shown, the current status. A function receives the current status so the name follows an uncontrolled choice.
Storybook
Interactive examples and edge cases for this component are in Storybook.
DefaultOpens in a new tab
Previous
User Menu / Usage
Next
User Menu / Accessibility
On this page
UserMenu
UserMenuItem
Enums
Props
Storybook