Components
User menu
A dropdown for the signed-in person's identity and account actions.
pnpm dlx shadcn@latest add @caliper/user-menuWhen to use
Use it for
- Account switching, settings and sign out in a header.
- You control the content; it implies no session behaviour.
Skip it when
- General actions that are not about the person; use a dropdown menu.
Installation
pnpm dlx shadcn@latest add @caliper/user-menu
Adds its 4 files to components/ui/, each with its own stylesheet, and installs their packages. No account needed. The first part also adds Caliper UI’s tokens; import them once as in Installation.
Usage
This is the code behind the preview above.
import { type ReactNode } from "react" import { Avatar } from "@/components/ui/avatar" import { Button } from "@/components/ui/button" import { DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator } from "@/components/ui/dropdown-menu" import { UserMenu } from "@/components/ui/user-menu" import { cn } from "@/components/ui/lib/cn" function Panel({ title, context, media, action, className, children }: { title: string; context: string; media?: ReactNode; action?: ReactNode; className?: string; children?: ReactNode }) { return ( <section className={cn("grid w-full max-w-md gap-5 rounded-overlay border border-border bg-background p-6 shadow-resting", className)}> <div className="flex items-center gap-3"> {media} <div className="grid min-w-0 flex-1 gap-1"> <p className="font-medium">{title}</p> <p className="text-sm text-muted-foreground">{context}</p> </div> {action} </div> {children} </section> ); } export function AccountMenu() { return ( <Panel title="Halden" context="Team plan · 14 seats" media={<Avatar name="Halden" shape="square" />} action={ <UserMenu trigger={<Button variant="ghost" size="icon" aria-label="Account"><Avatar name="Mara Chen" /></Button>}> <DropdownMenuLabel>mara@halden.example</DropdownMenuLabel> <DropdownMenuItem>Profile</DropdownMenuItem> <DropdownMenuItem>Billing</DropdownMenuItem> <DropdownMenuSeparator /> <DropdownMenuItem>Sign out</DropdownMenuItem> </UserMenu> } /> ); }
API reference
UserMenu
component
Also accepts the native props of its root element and a ref.
Accessibility
It is built on native elements, so roles and focus come from the browser.
Keyboard and focus handling comes from Radix dropdown-menu: arrow keys move through items, Enter and Space select, and Escape closes and returns focus.
Motion
It declares no animation in its component source. Any transition comes from its stylesheet, which uses the duration tokens that collapse to instant under prefers-reduced-motion.