Account menu
A sidebar's account row and its menu on the browser's own popover: works before script runs and in server-rendered pages.
npx shadcn@latest add @silicon-ui/account-menuInstallation
With the shadcn CLI
npx shadcn@latest add @silicon-ui/account-menuManually
Install the dependencies
npm install lucide-reactCopy these files into your project
- components/silicon-ui/account-menu/account-menu.tsx
- components/silicon-ui/account-menu/account-menu.module.css
Shared with other components. Skip any you already have.
- components/silicon-ui/lib/sidebar-rail.tsx
Add the foundation, once per app, for the design and motion tokens
npx shadcn@latest add @silicon-ui/silicon-foundation
Usage
API reference
AccountMenu
| Prop | Type | Default |
|---|---|---|
name*The signed-in account's name, on the row and at the head of the menu. | string | — |
children*The menu's rows: AccountMenuItem, AccountMenuSeparator, AccountMenuLabel, or a form holding an item (a sign-out that posts). Server-rendered nodes are fine. | ReactNode | — |
avatarSrcThe account's photo. Without it the row shows its initials. | string | — |
detailUnder the name at the head of the menu, such as "c:anil · Carbon". Without it the head shows the name alone. | string | — |
showIdentityShows the photo, name and detail at the head of the menu. Off when the rows already say who is signed in (an account switcher lists the current account first). | boolean | true |
presentation`menu` (default): the row opens the rows in a popover above it. `list`: the rows in place, with no row and no popover, for a phone sheet that already holds the sidebar. | "menu" | "list" | "menu" |
labelThe row's name for screen readers. Defaults to "Account, {name}". | string | — |
idThe popover's id. Defaults to a generated one. | string | — |
classNamePlacement only, on the row (or on the list). | string | — |
AccountMenuAvatar
| Prop | Type | Default |
|---|---|---|
name* | string | — |
src | string | — |
size | "sm" | "md" | "sm" |
AccountMenuItem
| Prop | Type | Default |
|---|---|---|
children*The row's words. | ReactNode | — |
iconAt the row's start: a 16px icon, or an account's photo (AccountMenuAvatar). | ReactNode | — |
descriptionA second line under the words, such as an account's id. | ReactNode | — |
trailingAt the row's end: a hint such as an arrow for a link that leaves the app. | ReactNode | — |
currentMarks the current choice (the signed-in account in a switcher) with a tick and aria-current. | boolean | false |
hrefMakes the row a link. Without it the row is a button (type="button", or type="submit" inside a form). | string | — |
targetFor a link: where it opens, such as "_blank". | string | — |
relFor a link: its rel, such as "noopener noreferrer". | string | — |
Also accepts the props of ButtonHTMLAttributes<HTMLButtonElement>, except children.
AccountMenuLabel
| Prop | Type | Default |
|---|---|---|
children* | ReactNode | — |
Dependencies
- npm
- lucide-react
- Registry
- silicon-motion-tokens