Skip to the page

Account menu

In code: AccountMenu

Who is signed in, and what they can do with their account: their picture, name and email, and a menu with Settings, their account page and Sign out. The same in every screen of an app, at the foot of the sidebar or in the top bar. The person's name and picture come from the account that signs them in; the app never lets them be changed here.

Preview

Profile

Use

The code of the preview above
import { AccountMenu, PageMenu, Row } from '@/components/ui';

<PageMenu
  label="Settings"
  side="start"
  items={[
    { href: '#profile', label: 'Profile', active: true },
    { href: '#team', label: 'Team' },
  ]}
  foot={
    <AccountMenu
      name="Ines Duarte"
      email="[email protected]"
      settingsHref="#settings"
      accountHref="#account"
      signOutAction="#"
    />
  }
>
  <Row between>
    <h3 className="ui-title">Profile</h3>
    <AccountMenu name="Ines Duarte" email="[email protected]" accountHref="#account" signOutAction="#" compact side="bottom" align="end" />
  </Row>
</PageMenu>

This page as text, for an AI

Options

OptionTypeWhat it does
name NeededstringThe person who is signed in.
accountHref stringWhere they change their own account (name, picture, password), on the site that signs them in. Opens in a new tab.
accountLabel stringThe name of that account page: "Your account" by default.
align "end" | "start" · default 'start'Which edge of the trigger the menu lines up with: start (the default) or end, for a trigger at the end of a top bar.
className stringMore classes on the outer element, for layout around it (margins, grid placement), not to restyle it.
compact booleanOnly the picture, for a top bar. Its name is still read out.
email stringTheir email, shown under the name.
note ReactNodeOne quiet line at the top of the menu: who this stand-in is, why there is no Sign out.
picture null | stringThe address of their picture. Left out, or if it fails, their initials show.
settingsHref stringWhere the settings of what they are using are, for someone allowed to change them. Left out, there is no Settings.
side "top" | "bottom" · default 'top'Where the menu opens: top for the foot of a sidebar (the default), bottom for a top bar.
signOutAction stringThe address Sign out sends a POST to. Left out, there is no Sign out (a stand-in, a demo).

Without React

The same look on any HTML, with the classes button.ui-account (+ --compact) > .ui-avatar + .ui-account-text; menu .ui-account-menu.

With the CSS in parts (/ui/css/), it needs these, besides the ones every page loads:

components/avatar.csscomponents/account-menu.cssparts/avatar.css

Layout: states, do and don’t

Who is signed in: their picture (their initials without one), name and email in one row at the foot of a sidebar or of a PageMenu (compact: only the picture, for a top bar, with side="bottom"), opening a menu with Settings (settingsHref, for someone allowed to change them), their account page (accountHref, in a new tab, named by accountLabel) and Sign out (signOutAction, sent as a POST). Leave out what someone may not do. note is one quiet line at the top of the menu, such as who a stand-in is. The name and picture come from the account that signs people in: an app shows them, never changes them.

States. Layout follows the box it is in, not the window: Split, Grid, AppShell and the site parts stack when their box is narrow, at any width of the window.

Do

  • Space with gap (Stack, Row, Grid), never with margins on children.
  • Put the page's sections straight on the page, under their titles; a Card is one thing a person picks or acts on.
  • Check every screen at 320, 375 and 768 px with the narrow check of rule 10.

Don't

  • Don't give a box a fixed width, or a min-height together with an aspect-ratio.
  • Don't nest a card in a card.
  • Don't put two <main>s on a page: a screen shown inside another page takes Main as="div".