Skip to content

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.

NavigationSidebarProduct
npx shadcn@latest add @silicon-ui/account-menu

Installation

With the shadcn CLI

npx shadcn@latest add @silicon-ui/account-menu

Manually

  1. Install the dependencies

    npm install lucide-react
  2. Copy 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
  3. Add the foundation, once per app, for the design and motion tokens

    npx shadcn@latest add @silicon-ui/silicon-foundation

Usage

usage.tsx
import { AccountMenu } from "@/components/silicon-ui/account-menu/account-menu";

API reference

AccountMenu

PropTypeDefault
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—
avatarSrc

The account's photo. Without it the row shows its initials.

string—
detail

Under the name at the head of the menu, such as "c:anil · Carbon". Without it the head shows the name alone.

string—
showIdentity

Shows 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).

booleantrue
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"
label

The row's name for screen readers. Defaults to "Account, {name}".

string—
id

The popover's id. Defaults to a generated one.

string—
className

Placement only, on the row (or on the list).

string—

AccountMenuAvatar

PropTypeDefault
name*string—
srcstring—
size"sm" | "md""sm"

AccountMenuItem

PropTypeDefault
children*

The row's words.

ReactNode—
icon

At the row's start: a 16px icon, or an account's photo (AccountMenuAvatar).

ReactNode—
description

A second line under the words, such as an account's id.

ReactNode—
trailing

At the row's end: a hint such as an arrow for a link that leaves the app.

ReactNode—
current

Marks the current choice (the signed-in account in a switcher) with a tick and aria-current.

booleanfalse
href

Makes the row a link. Without it the row is a button (type="button", or type="submit" inside a form).

string—
target

For a link: where it opens, such as "_blank".

string—
rel

For a link: its rel, such as "noopener noreferrer".

string—

Also accepts the props of ButtonHTMLAttributes<HTMLButtonElement>, except children.

AccountMenuLabel

PropTypeDefault
children*ReactNode—

Dependencies

npm
lucide-react
Registry
silicon-motion-tokens