{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"account-card","title":"Account Card","description":"Show the signed-in account in a sidebar and open a menu with its actions, a list of accounts to switch to and sign out. Search terms: account switcher, account menu, user menu, profile menu, switch account.","dependencies":["@phosphor-icons/react@2.1.10"],"registryDependencies":["@siteplane/base","@siteplane/avatar","@siteplane/avatar-label-group","@siteplane/button","@siteplane/card","@siteplane/menu","@siteplane/sidebar"],"files":[{"path":"packages/ui/src/components/account-card/account-card.tsx","content":"\"use client\";\n\nimport * as React from \"react\";\n\nimport { useSiteplaneMessages } from \"../../system/locale/messages-context\";\nimport { cn } from \"../../system/utils/cn\";\nimport { slotClass } from \"../../system/utils/slot-class\";\nimport { AvatarLabelGroup } from \"../avatar-label-group\";\nimport { Button } from \"../button\";\nimport { KitButton } from \"../button/button-internal\";\nimport { Card } from \"../card\";\nimport { Menu, MenuPopup, MenuTrigger } from \"../menu\";\nimport {\n  SidebarContext,\n  SidebarMenu,\n  SidebarMenuButton,\n  SidebarMenuButtonDescription,\n  SidebarMenuButtonText,\n  SidebarMenuButtonTitle,\n  SidebarMenuChevron,\n  SidebarMenuItem,\n} from \"../sidebar\";\nimport {\n  type AccountMenuAccount,\n  AccountMenuAvatar,\n  AccountMenuCaret,\n  AccountMenuContent,\n} from \"./account-menu-content\";\n\n/**\n * An account the trigger shows and the menu lists: its `id`, its `name`, the\n * `email` under the name (in the row, the card and the header of the menu),\n * the avatar's `src` and `initials`, its `shape`, `square` for a company or a\n * workspace (rulebook B10), and the `status` dot at the corner of the current\n * account's avatar.\n */\nexport type AccountCardAccount = AccountMenuAccount;\n\n/** An action row of the account menu: a link with `href`, an action without. */\nexport type AccountCardAction = {\n  label: string;\n  /** The leading icon, 16 px in the row's icon slot. Give it aria-hidden. */\n  icon?: React.ReactNode;\n  /** A keyboard shortcut shown at the end of the row; display only. */\n  shortcut?: string | undefined;\n  href?: string | undefined;\n  onClick?: (() => void) | undefined;\n};\n\nexport interface AccountCardProps extends Omit<\n  React.ComponentProps<\"div\">,\n  \"children\"\n> {\n  /**\n   * The accounts. The one whose `id` is `accountId` fills the trigger, and\n   * with more than one the menu lists them all to switch between.\n   */\n  accounts: readonly AccountCardAccount[];\n  /** The current account; the first of `accounts` when none matches. */\n  accountId?: string | undefined;\n  /** Called with the id of the account that is picked in the menu. */\n  onAccountChange?: ((id: string) => void) | undefined;\n  /** The action rows of the menu, after its header, such as View profile. */\n  items?: readonly AccountCardAction[] | undefined;\n  /**\n   * The label above the account list and the name of its group, \"Switch\n   * account\" by default.\n   */\n  accountsLabel?: string | undefined;\n  /** Shows the Add account row under the account list and is called by it. */\n  onAddAccount?: (() => void) | undefined;\n  /** The label of the add row, \"Add account\" by default. */\n  addAccountLabel?: string | undefined;\n  /** Shows the Sign out row at the end of the menu and is called by it. */\n  onSignOut?: (() => void) | undefined;\n  /** The label of the sign out row, \"Sign out\" by default. */\n  signOutLabel?: string | undefined;\n  /**\n   * What the button that opens the menu does, \"Account menu\" by default. On\n   * the row and the card it follows the account's name, as in \"Mara Ellis,\n   * Account menu\", and it names the avatar button alone. The menu takes its\n   * name from the button.\n   */\n  label?: string | undefined;\n  /**\n   * `row`, the default, shows the account as the sidebar's own two-line row:\n   * a 32 px avatar, the name over the email and the switcher caret, with the\n   * row's hover, pressed and open fills and no card around it. In a Sidebar\n   * it is a 48 px SidebarMenuButton, and on the collapsed icon rail the\n   * rail's square with a 20 px avatar. `card` shows the avatar, name and\n   * email in a card that is one button. `avatar` shows only the avatar, as a\n   * button, for the collapsed icon rail of a slim sidebar. Every trigger\n   * opens the menu beside it, with the account's avatar, name and email at\n   * its top.\n   */\n  trigger?: \"row\" | \"card\" | \"avatar\" | undefined;\n}\n\n/**\n * The account of a sidebar: the signed-in account's avatar, name and email as\n * one button, which opens the account menu beside it. By default it is the\n * sidebar's own two-line row; `trigger=\"card\"` shows it in a card and\n * `trigger=\"avatar\"` shows only the avatar, for the collapsed rail of a slim\n * sidebar. The menu is the kit's Menu: a header with the account's avatar,\n * name and email, the account's actions, such as View profile and Account\n * settings, a list of the accounts to switch to, Add account and, under a\n * separator, Sign out.\n */\nexport function AccountCard({\n  accountId,\n  accounts,\n  accountsLabel,\n  addAccountLabel,\n  className,\n  items = [],\n  label: labelProp,\n  onAccountChange,\n  onAddAccount,\n  onSignOut,\n  ref,\n  signOutLabel,\n  trigger = \"row\",\n  ...props\n}: AccountCardProps): React.ReactElement | null {\n  // The texts of the menu's rows are the account menu's own (AccountMenuContent).\n  const messages = useSiteplaneMessages(\"accountCard\");\n  const label = labelProp ?? messages.label;\n  // In a Sidebar the menu follows its place: beside a docked sidebar, above\n  // the trigger in a sheet. Outside one it opens beside the trigger.\n  const sidebar = React.useContext(SidebarContext);\n  const card = React.useRef<HTMLDivElement | null>(null);\n  // The card's own ref anchors the menu; a ref the app passes reaches the\n  // same element beside it rather than taking its place.\n  const setCard = React.useCallback(\n    (element: HTMLDivElement | null) => {\n      card.current = element;\n      if (typeof ref === \"function\") ref(element);\n      else if (ref) ref.current = element;\n    },\n    [ref],\n  );\n  const current =\n    accounts.find((account) => account.id === accountId) ?? accounts[0];\n  if (!current) return null;\n  const mobile = sidebar?.isMobile ?? false;\n  // Every trigger opens the menu with the account's avatar, name and email\n  // (Lukas, 15 November 2026: it reverses C8a of 3 November, where only the\n  // avatar's menu showed them). Beside the sidebar\n  // the menu opens towards the content, its bottom on the trigger's; in a\n  // sheet it opens above the trigger. The row's menu is at least as wide as\n  // the row, so above it in a sheet it takes the row's width.\n  const popup = (\n    <MenuPopup\n      align=\"end\"\n      anchor={trigger === \"card\" ? card : undefined}\n      side={mobile ? \"top\" : \"inline-end\"}\n      sideOffset={8}\n      width={trigger === \"row\" ? \"at-least-trigger\" : \"auto\"}\n    >\n      {/* The kit's account menu, which HeaderAccountMenu shares. */}\n      <AccountMenuContent\n        accountId={current.id}\n        accounts={accounts}\n        accountsLabel={accountsLabel}\n        addAccountLabel={addAccountLabel}\n        header={current}\n        items={items}\n        onAccountChange={onAccountChange}\n        onAddAccount={onAddAccount}\n        onSignOut={onSignOut}\n        signOutLabel={signOutLabel}\n      />\n    </MenuPopup>\n  );\n\n  if (trigger === \"avatar\") {\n    return (\n      <Menu>\n        <MenuTrigger\n          aria-label={label}\n          className={className}\n          render={<Button profile=\"avatar\" variant=\"ghost\" />}\n        >\n          {/* The rail's square, as its rows: a 32 px avatar in the 36 px\n              circle of the avatar profile at the control size. The avatar\n              names its size, so the profile keeps it, with a presence dot\n              or without (button.css). */}\n          <AccountMenuAvatar\n            account={current}\n            bordered\n            size=\"sm\"\n            status={current.status}\n          />\n        </MenuTrigger>\n        {popup}\n      </Menu>\n    );\n  }\n\n  if (trigger === \"row\") {\n    // The sidebar's own two-line row: its 48 px row, a 32 px avatar, the\n    // name over the email in the two-line row's text and the switcher caret\n    // (rulebook M9), with the navigation row's fills and no card (Lukas,\n    // 15 November 2026). On the collapsed\n    // icon rail it is the rail's 36 px square with the 20 px of a row icon,\n    // as every two-line row (B10). Outside a Sidebar it is the same row, the\n    // Button's navigation row, which needs no Sidebar around it.\n    const collapsed =\n      sidebar !== null && sidebar.state === \"collapsed\" && !sidebar.isMobile;\n    const menu = (\n      <Menu>\n        <MenuTrigger\n          aria-label={`${current.name}, ${label}`}\n          data-slot=\"account-card-trigger\"\n          render={\n            sidebar ? (\n              <SidebarMenuButton size={collapsed ? \"sm\" : \"xl\"} type=\"button\" />\n            ) : (\n              <KitButton\n                align=\"start\"\n                profile=\"navigation-row\"\n                size=\"xl\"\n                type=\"button\"\n                variant=\"ghost\"\n                width=\"full\"\n              />\n            )\n          }\n        >\n          <AccountMenuAvatar\n            account={current}\n            aria-hidden=\"true\"\n            size={collapsed ? \"2xs\" : \"sm\"}\n            status={current.status}\n          />\n          <SidebarMenuButtonText>\n            <SidebarMenuButtonTitle>{current.name}</SidebarMenuButtonTitle>\n            {current.email ? (\n              <SidebarMenuButtonDescription>\n                {current.email}\n              </SidebarMenuButtonDescription>\n            ) : null}\n          </SidebarMenuButtonText>\n          <SidebarMenuChevron variant=\"switcher\" />\n        </MenuTrigger>\n        {popup}\n      </Menu>\n    );\n    return (\n      <div\n        className={cn(slotClass(\"account-card\", props), className)}\n        data-slot=\"account-card\"\n        ref={ref}\n        {...props}\n      >\n        {sidebar ? (\n          <SidebarMenu>\n            <SidebarMenuItem>{menu}</SidebarMenuItem>\n          </SidebarMenu>\n        ) : (\n          menu\n        )}\n      </div>\n    );\n  }\n\n  return (\n    // A Card with its 12 px inset around the avatar and the text, which end\n    // 8 px before the chevron (Lukas, 3 November 2026, C8c: the whole card\n    // opens the menu, the chevron centred). The card is its root, `card`;\n    // the class of the row's root, account-card, stays off it (P6).\n    <Card\n      className={cn(\"flex-row items-center gap-3 p-3 pe-9\", className)}\n      ref={setCard}\n      {...props}\n    >\n      <AvatarLabelGroup size=\"md\" subtitle={current.email} title={current.name}>\n        <AccountMenuAvatar account={current} status={current.status} />\n      </AvatarLabelGroup>\n      <Menu>\n        {/* The card is one button: a ghost Button laid over the whole card,\n            as Attachment's trigger lies over its card, with the card's\n            corners, so the Button's own hover, pressed and open fills and its\n            focus ring cover the card, from the navigation treatment of the\n            kit's ghost navigation triggers (rulebook T5). Its one glyph is\n            the caret of every account trigger (AccountMenuCaret), 16 px,\n            tertiary at rest and primary on hover, press and while the menu\n            is open, as on HeaderAccountMenu's card trigger. The caret is\n            centred on the card's height at the card's inset. The button is\n            named by the account's name and what it does. */}\n        <MenuTrigger\n          aria-label={`${current.name}, ${label}`}\n          data-slot=\"account-card-trigger\"\n          render={\n            <Button\n              className=\"absolute inset-0 size-full justify-end rounded-[inherit] pe-3\"\n              profile=\"navigation-link\"\n              size=\"xs\"\n              variant=\"ghost\"\n            />\n          }\n        >\n          <AccountMenuCaret />\n        </MenuTrigger>\n        {popup}\n      </Menu>\n    </Card>\n  );\n}\n","type":"registry:ui","target":"~/src/siteplane/components/account-card/account-card.tsx"},{"path":"packages/ui/src/components/account-card/account-menu-content.tsx","content":"\"use client\";\n\nimport {\n  MoonIcon,\n  PlusIcon,\n  SignOutIcon,\n} from \"@phosphor-icons/react/dist/ssr\";\nimport type * as React from \"react\";\n\nimport { useSiteplaneMessages } from \"../../system/locale/messages-context\";\nimport {\n  Avatar,\n  AvatarFallback,\n  AvatarImage,\n  type AvatarShape,\n  type AvatarStatus,\n} from \"../avatar\";\nimport { AvatarLabelGroup } from \"../avatar-label-group\";\nimport {\n  MenuCheckboxItem,\n  MenuGroup,\n  MenuGroupLabel,\n  MenuHeader,\n  MenuItem,\n  MenuLinkItem,\n  MenuRadioGroup,\n  MenuRadioItem,\n  MenuSeparator,\n  MenuShortcut,\n  MenuSub,\n  MenuSubPopup,\n  MenuSubTrigger,\n  MenuTriggerIcon,\n} from \"../menu\";\n\n/*\n * The account menu of the kit, one owner for every account menu: Account\n * Card's and Header Navigation's HeaderAccountMenu compose it inside their\n * MenuPopup, so their rows, avatars, checks and texts are one (Lukas, 3\n * November 2026). Internal: the index of Account Card does not export it.\n */\n\n/** An account of the account menu. */\nexport type AccountMenuAccount = {\n  id: string;\n  /** The account holder's name. */\n  name: string;\n  /** The line under the name, such as the email address. */\n  email?: string | undefined;\n  /** The avatar image. */\n  src?: string | undefined;\n  /** The initials the avatar shows while it has no image. */\n  initials?: string | undefined;\n  /**\n   * The avatar's shape: `square` for a company or a workspace, such as an\n   * organisation's account; a person keeps the circle (rulebook B10). Every\n   * avatar of the account takes it: its row, the header band and a trigger.\n   */\n  shape?: AvatarShape | undefined;\n  /** The presence dot at the corner of the account's avatar. */\n  status?: AvatarStatus | undefined;\n};\n\n/**\n * A row of the account menu: a link with `href`, an action without, and a\n * submenu of its `children`.\n */\nexport type AccountMenuAction = {\n  label: string;\n  /** The leading icon, 16 px in the row's icon slot. Give it aria-hidden. */\n  icon?: React.ReactNode;\n  /** A keyboard shortcut shown at the end of the row; display only. */\n  shortcut?: string | undefined;\n  href?: string | undefined;\n  onClick?: (() => void) | undefined;\n  /** The rows of a submenu, which this row opens. */\n  children?: readonly AccountMenuAction[] | undefined;\n};\n\nexport type AccountMenuContentProps = {\n  /**\n   * The account whose avatar, name and email head the menu in a header band.\n   * Every trigger of the account menu passes its current account, the row,\n   * the card and the avatar (Lukas, 15 November 2026; on 3 November, C8a,\n   * only a trigger that showed no name passed it).\n   */\n  header?: AccountMenuAccount | undefined;\n  /** The action rows, after the header, such as View profile. */\n  items?: readonly AccountMenuAction[] | undefined;\n  /** Shows a dark mode switch row after the action rows and is called by it. */\n  onDarkModeChange?: ((dark: boolean) => void) | undefined;\n  darkMode?: boolean | undefined;\n  darkModeLabel?: string | undefined;\n  /** A second group of action rows, after a separator. */\n  secondaryItems?: readonly AccountMenuAction[] | undefined;\n  /** The accounts; with more than one, the menu lists them to switch between. */\n  accounts?: readonly AccountMenuAccount[] | undefined;\n  /** The account whose row is checked. */\n  accountId?: string | undefined;\n  onAccountChange?: ((id: string) => void) | undefined;\n  accountsLabel?: string | undefined;\n  /** Shows the Add account row under the account list and is called by it. */\n  onAddAccount?: (() => void) | undefined;\n  addAccountLabel?: string | undefined;\n  /** Shows the Sign out row at the end of the menu and is called by it. */\n  onSignOut?: (() => void) | undefined;\n  signOutLabel?: string | undefined;\n};\n\n/**\n * An account's avatar in the account's shape; it names no size, so its scope\n * or row sizes it.\n */\nexport function AccountMenuAvatar({\n  account,\n  ...props\n}: {\n  account: AccountMenuAccount;\n} & Omit<React.ComponentProps<typeof Avatar>, \"children\">): React.ReactElement {\n  return (\n    <Avatar shape={account.shape} {...props}>\n      <AvatarImage alt=\"\" src={account.src} />\n      <AvatarFallback>\n        {account.initials ?? account.name.charAt(0)}\n      </AvatarFallback>\n    </Avatar>\n  );\n}\n\n/**\n * The caret of a trigger that opens the account menu: Account Card's card and\n * HeaderAccountMenu's card trigger; Account Card's row, a Sidebar row, ends\n * with SidebarMenuChevron `variant=\"switcher\"`, which draws the same caret.\n * It is the switcher caret of every\n * switcher, `MenuTriggerIcon variant=\"switcher\"`: the still up-down caret,\n * 16 px, tertiary at rest and primary on hover, press and while its menu is\n * open (rulebook M9; Lukas, 3 November 2026, C8c, and 4 November 2026: the\n * account caret was a glyph and a rule of its own).\n */\nexport function AccountMenuCaret(): React.ReactElement {\n  return <MenuTriggerIcon variant=\"switcher\" />;\n}\n\n/**\n * An action row: its icon, its label and its shortcut at the end, as a link\n * row with `href`, as an action row without, and as a submenu trigger with\n * `children`. The row's own children are written in place, so the menu row\n * lays out the icon and the shortcut.\n */\nfunction ActionRow({ action }: { action: AccountMenuAction }) {\n  if (action.children)\n    return (\n      <MenuSub>\n        <MenuSubTrigger>\n          {action.icon}\n          {action.label}\n        </MenuSubTrigger>\n        <MenuSubPopup>\n          {action.children.map((child) => (\n            <ActionRow action={child} key={child.label} />\n          ))}\n        </MenuSubPopup>\n      </MenuSub>\n    );\n  const shortcut = action.shortcut ? (\n    <MenuShortcut>{action.shortcut}</MenuShortcut>\n  ) : null;\n  if (action.href)\n    return (\n      <MenuLinkItem href={action.href} onClick={action.onClick}>\n        {action.icon}\n        {action.label}\n        {shortcut}\n      </MenuLinkItem>\n    );\n  return (\n    <MenuItem onClick={action.onClick}>\n      {action.icon}\n      {action.label}\n      {shortcut}\n    </MenuItem>\n  );\n}\n\n/**\n * The rows of the account menu, in this order, each part only with something\n * to show and divided from the part before it by a separator: the header band\n * (`header`), the action rows with the dark mode switch, the second group of\n * rows, the accounts to switch between with Add account, and Sign out. Put it\n * in a MenuPopup.\n */\nexport function AccountMenuContent({\n  accountId,\n  accounts = [],\n  accountsLabel: accountsLabelProp,\n  addAccountLabel: addAccountLabelProp,\n  darkMode,\n  darkModeLabel: darkModeLabelProp,\n  header,\n  items = [],\n  onAccountChange,\n  onAddAccount,\n  onDarkModeChange,\n  onSignOut,\n  secondaryItems = [],\n  signOutLabel: signOutLabelProp,\n}: AccountMenuContentProps): React.ReactElement {\n  const messages = useSiteplaneMessages(\"accountCard\");\n  const accountsLabel = accountsLabelProp ?? messages.accounts;\n  const addAccountLabel = addAccountLabelProp ?? messages.addAccount;\n  const darkModeLabel = darkModeLabelProp ?? messages.darkMode;\n  const signOutLabel = signOutLabelProp ?? messages.signOut;\n  const actions = items.length > 0 || onDarkModeChange !== undefined;\n  const secondary = secondaryItems.length > 0;\n  const switching = accounts.length > 1;\n  const accountRows = switching || onAddAccount !== undefined;\n  return (\n    <>\n      {header ? (\n        // The menu opens with a header band of the account's avatar, name and\n        // email, whose menu it is (Lukas, 15 November 2026).\n        <MenuHeader>\n          <AvatarLabelGroup\n            size=\"md\"\n            subtitle={header.email}\n            title={header.name}\n          >\n            <AccountMenuAvatar account={header} aria-hidden=\"true\" />\n          </AvatarLabelGroup>\n        </MenuHeader>\n      ) : null}\n      {items.map((action) => (\n        <ActionRow action={action} key={action.label} />\n      ))}\n      {onDarkModeChange ? (\n        // A switch row keeps its menu open on its own, and its icon comes\n        // first, so the label starts at the other rows' x (I8).\n        <MenuCheckboxItem\n          checked={darkMode}\n          onCheckedChange={onDarkModeChange}\n          variant=\"switch\"\n        >\n          <MoonIcon aria-hidden=\"true\" />\n          {darkModeLabel}\n        </MenuCheckboxItem>\n      ) : null}\n      {secondary ? (\n        <>\n          {actions ? <MenuSeparator /> : null}\n          {secondaryItems.map((action) => (\n            <ActionRow action={action} key={action.label} />\n          ))}\n        </>\n      ) : null}\n      {accountRows && (actions || secondary) ? <MenuSeparator /> : null}\n      {switching ? (\n        <MenuGroup>\n          <MenuGroupLabel>{accountsLabel}</MenuGroupLabel>\n          <MenuRadioGroup\n            onValueChange={(value) => onAccountChange?.(String(value))}\n            value={accountId}\n          >\n            {/* Identity rows: the avatar leads in the slot of the row's icon,\n                20 px as it names no size, and the check ends the current\n                account's row (rulebook I8). The name names the row, so the\n                avatar and its initials stay out of its accessible name. A\n                picked row closes the menu, as every radio row does (B9). */}\n            {accounts.map((account) => (\n              <MenuRadioItem key={account.id} value={account.id}>\n                <AccountMenuAvatar account={account} aria-hidden=\"true\" />\n                {account.name}\n              </MenuRadioItem>\n            ))}\n          </MenuRadioGroup>\n        </MenuGroup>\n      ) : null}\n      {onAddAccount ? (\n        <MenuItem onClick={onAddAccount}>\n          <PlusIcon aria-hidden=\"true\" />\n          {addAccountLabel}\n        </MenuItem>\n      ) : null}\n      {onSignOut ? (\n        <>\n          {/* Sign out is a plain row under a separator, with its icon and\n              without a shortcut (Lukas, 3 November 2026). */}\n          {actions || secondary || accountRows ? <MenuSeparator /> : null}\n          <MenuItem onClick={onSignOut}>\n            <SignOutIcon aria-hidden=\"true\" />\n            {signOutLabel}\n          </MenuItem>\n        </>\n      ) : null}\n    </>\n  );\n}\n","type":"registry:ui","target":"~/src/siteplane/components/account-card/account-menu-content.tsx"},{"path":"packages/ui/src/components/account-card/index.ts","content":"export * from \"./account-card\";\n","type":"registry:ui","target":"~/src/siteplane/components/account-card/index.ts"}],"type":"registry:ui","docs":"https://ui.siteplane.io/docs-markdown/components/account-card.md","categories":["Navigation"],"meta":{"avoidWhen":["Avoid in a header bar; use the account menu of Header Navigation or a Menu with an avatar trigger.","Avoid for a list of settings; link to a settings page from an action row instead."],"description":"Show the signed-in account in a sidebar and open a menu with its actions, a list of accounts to switch to and sign out.","knownLimitations":["The menu has no controlled open state; make a row that leads to another page a link with href.","Shortcuts are labels only; the card registers no keys."],"providerNotes":[],"releaseStatus":"preview","searchTerms":["account card","account switcher","account menu","user menu","profile menu","switch account","sign out"],"useWhen":["Use at the foot of an application sidebar for the signed-in account, its actions, an account switcher and sign out.","Use trigger avatar on the collapsed icon rail of a slim sidebar."]}}