Skip to content
caliper ui docs

Components

Dropdown menu

A menu of actions anchored to a trigger, with groups, shortcuts and separators.

Free
pnpm dlx shadcn@latest add @caliper/dropdown-menu

Finance · Q3 close

Shared folder · Priya Nair and 4 others

  • Q3 reconciliation.csvCSV · 1.2 MB
  • Bank export October.csvCSV · 880 KB
  • Close checklist.pdfPDF · 2.4 MB

3 files selected

Installs components/ui/dropdown-menu.tsxDepends on @radix-ui/react-dropdown-menu, lucide-reactMotion none in component source

When to use

Use it for

  • Row, toolbar and account menus with several actions.
  • Items that deserve keyboard shortcuts or a destructive style.

Skip it when

  • One action is the default; use a split button.
  • The choice sets a form value; use a select.

Installation

terminal
pnpm dlx shadcn@latest add @caliper/dropdown-menu

Adds its 3 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

example.tsx
import { Copy, FileText, FolderOpen, Pencil, Trash2 } from "lucide-react"
import { useState, type ReactNode } from "react"
import { Button } from "@/components/ui/button"
import { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuConfirmItem, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuTrigger } from "@/components/ui/dropdown-menu"
import { cn } from "@/components/ui/lib/cn"

function Panel({ title, context, children, className }: { title: ReactNode; context: ReactNode; children: ReactNode; className?: string }) {
  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="grid gap-1">
        <p className="font-medium">{title}</p>
        <p className="text-sm text-muted-foreground">{context}</p>
      </div>
      {children}
    </section>
  );
}

const files = [
  { name: "Q3 reconciliation.csv", meta: "CSV · 1.2 MB" },
  { name: "Bank export October.csv", meta: "CSV · 880 KB" },
  { name: "Close checklist.pdf", meta: "PDF · 2.4 MB" },
];

export function ProjectMenu() {
  const [status, setStatus] = useState("3 files selected");
  const [sidebar, setSidebar] = useState(true);
  return (
    <div className="grid w-full justify-items-center pb-40">
      <Panel title="Finance · Q3 close" context="Shared folder · Priya Nair and 4 others">
        <ul className="grid gap-2 text-sm">
          {files.map((file) => (
            <li key={file.name} className="flex items-center gap-3">
              <FileText aria-hidden="true" className="size-4 text-muted-foreground" />
              <span className="min-w-0 flex-1 truncate">{file.name}</span>
              <span className="text-muted-foreground">{file.meta}</span>
            </li>
          ))}
        </ul>
        <div className="flex flex-wrap items-center justify-between gap-3">
          <p role="status" className="text-sm text-muted-foreground">{status}</p>
          <DropdownMenu>
            <DropdownMenuTrigger asChild>
              <Button variant="secondary">File actions</Button>
            </DropdownMenuTrigger>
            <DropdownMenuContent align="end" className="w-64">
              <DropdownMenuLabel>3 files selected</DropdownMenuLabel>
              <DropdownMenuItem onSelect={() => setStatus("Opened 3 files in new tabs.")}><FolderOpen aria-hidden="true" />Open<DropdownMenuShortcut>↵</DropdownMenuShortcut></DropdownMenuItem>
              <DropdownMenuItem onSelect={() => setStatus("Renaming Q3 reconciliation.csv…")}><Pencil aria-hidden="true" />Rename<DropdownMenuShortcut>F2</DropdownMenuShortcut></DropdownMenuItem>
              <DropdownMenuItem onSelect={() => setStatus("Duplicated 3 files.")}><Copy aria-hidden="true" />Duplicate<DropdownMenuShortcut>⌘D</DropdownMenuShortcut></DropdownMenuItem>
              <DropdownMenuSeparator />
              <DropdownMenuCheckboxItem checked={sidebar} onCheckedChange={(value) => setSidebar(value === true)}>Show in sidebar</DropdownMenuCheckboxItem>
              <DropdownMenuSeparator />
              <DropdownMenuConfirmItem
                label="Delete 3 files"
                icon={<Trash2 aria-hidden="true" />}
                question="Delete 3 files?"
                detail="They move to Trash for 30 days."
                onConfirm={() => setStatus("Moved 3 files to Trash. Restore within 30 days.")}
              />
            </DropdownMenuContent>
          </DropdownMenu>
        </div>
      </Panel>
    </div>
  );
}

API reference

DropdownMenu

component

No props of its own; it accepts the native props of its root element.

DropdownMenuTrigger

component

No props of its own; it accepts the native props of its root element.

DropdownMenuContent

component

No props of its own; it accepts the native props of its root element.

DropdownMenuGroup

component

No props of its own; it accepts the native props of its root element.

DropdownMenuItem

component

No props of its own; it accepts the native props of its root element.

DropdownMenuCheckboxItem

component

No props of its own; it accepts the native props of its root element.

DropdownMenuRadioGroup

component

No props of its own; it accepts the native props of its root element.

DropdownMenuRadioItem

component

No props of its own; it accepts the native props of its root element.

DropdownMenuLabel

component

No props of its own; it accepts the native props of its root element.

DropdownMenuSeparator

component

No props of its own; it accepts the native props of its root element.

DropdownMenuShortcut

component

No props of its own; it accepts the native props of its root element.

DropdownMenuConfirmItem

component
PropTypeDefaultDescription
label *string—
iconReactNode—
question *string—e.g. "Delete 3 files?"
detailstring—e.g. "They move to Trash for 30 days."
confirmLabelstring"Delete"
onConfirm *() => void—

Accessibility

It exposes group semantics, with aria-hidden and aria-label kept in step with state.

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.

All Actions examples