UserMenu

Signed-in account menu. The avatar opens a card that grows from its corner; arrows, Home and End move through items, and Escape or a click outside closes it and returns focus to the avatar. Auth.

Open playground

About

UserMenu is a React component in the Auth category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { UserMenu } from "@ashutoshswamy/smoui" and set name, items, onSignOut among its 4 props.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { UserMenu } from "@ashutoshswamy/smoui";

<UserMenu
  name="Mara Okonkwo"
  email="mara@smoui.dev"
  items={[{ id: "profile", label: "Your profile", href: "/me" }, { id: "settings", label: "Settings", hint: "," }]}
  onSignOut={() => signOut()}
/>

Props 4

name / email / avatar

Account details. Without avatar, one is generated from the name.

string
items

Menu rows.

{ id: string; label: string; hint?: string; href?: string; onSelect?: () => void }[]
onSignOut

Adds a red Sign out at the bottom.

() => void
align

Which edge the card lines up with.

"end""start"default "end"