Each product wrote its own account menu, and each learned half of what
the other had:
Loki AccountMenu OrangeCat UserProfileDropdown
initials from the name only never rebuilds a name from the email
custom rows (Appearance) photo with a fallback, arrow keys
36px trigger 44px trigger
name falls back to the —
email local-part
and Loki's public pages had no menu at all, so a signed-in person could
not find sign-out (loki#870 papered over that by reusing the app's menu).
This is the one menu with both halves. It knows nothing about how a
product signs people in — NextAuth, Supabase, better-auth all pass the
person, the places, and a sign-out function — and keeps routing with a
renderLink seam (Next <Link>; a plain <a> by default).
Shared and not configurable, because each shipped broken somewhere:
- the name is never built from the email (OrangeCat's rule; Loki broke it)
- initials only from the name; else a person glyph
- a broken photo falls back to initials
- 44px trigger and rows; the panel never runs off a 390px screen
- Escape closes and returns focus wherever focus was
- sign-out says it is happening, and says when it FAILED (menu stays open)
The real-browser check caught a bug before release: Escape did nothing
after a MOUSE open, because the handler sat on the panel and focus was
on the trigger. It is now a document listener while open.
Styled from @bitbaum/design-tokens through --acct-* variables at zero
specificity (chatkit's pattern), so an app's own :root wins and an OKLCH
app maps its tokens once.
dist/ is committed so `github:bitbaum/accountkit#v0.1.0` installs with no
build and no allowBuilds entry; CI fails if it drifts from the source.
verify: format, lint, types, build, 13 unit+render tests, browser checks
at 390px light and dark. Proved by mutation — letting the name fall back
to the email local-part fails "a name is NEVER reconstructed from the
email address".
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@bitbaum/accountkit
One account menu for every bitbaum product: who is signed in, where to go, how to sign out.
Each product had written its own — Loki's AccountMenu, OrangeCat's UserProfileDropdown — and each had learned half of what the other had. Loki took initials only from the name; OrangeCat never rebuilt a name from the email address; OrangeCat had arrow keys and a 44px target, Loki had neither; Loki's public pages had no menu at all, so a signed-in person could not find sign-out. This is the one menu, with both halves.
It knows nothing about how you sign in. NextAuth, Supabase, better-auth: you pass the person, the places, and a sign-out function.
Install
pnpm add github:bitbaum/accountkit#v0.1.0
dist/ is committed, so the github: install needs no build step and no allowBuilds entry.
import "@bitbaum/accountkit/styles.css";
import { AccountMenu } from "@bitbaum/accountkit";
Use
<AccountMenu
user={{ name: session.user.name, email: session.user.email, image: session.user.image }}
groups={[{ id: "nav", items: [{ id: "settings", label: "Settings", href: "/settings" }] }]}
extra={<ThemeToggle />}
onSignOut={() => signOut({ callbackUrl: "/sign-in" })}
renderLink={(props) => <Link {...props} />}
/>
onSignOutmay return a promise. While it runs the row says so; if it rejects, the menu stays open and says sign-out did not complete. A sign-out that fails silently is the one thing this menu must never do.renderLinkkeeps your router (Next<Link>); the default is a plain<a>.extrais for rows that are not places, such as a theme switch.labelstranslates every string:labels={{ trigger: "Konto: {name}", signOut: "Abmelden" }}.
What is shared, and not configurable
- The name is never built from the email. No name:
@handle. No handle: "Account". - Initials come from the name only. No name and no photo: a person glyph.
- A photo that fails to load falls back to initials, then the glyph.
- 44px trigger and rows. The panel never runs off a 320–390px screen.
- Escape closes and returns focus to the trigger, wherever focus was. Arrows, Home and End move between items. A click outside closes.
Theming
Every colour, radius and font is an --acct-* variable. The defaults read @bitbaum/design-tokens at zero specificity, so apps on those tokens match with no work and an app's own :root always wins. An app whose tokens are full colours rather than HSL triplets (Loki's are OKLCH) maps them once:
:root {
--acct-panel: var(--surface-overlay);
--acct-fg: var(--text-primary);
/* … */
}
Verify
pnpm run verify # format, lint, types, build, unit + render tests, real-browser checks
The browser checks run the demo at 390px in light and dark: 44px targets, no sideways scroll with the menu open, Escape after a mouse open, arrow keys, outside click, a broken photo, an anonymous account, and a failing sign-out.
MIT.