Skip to content
HomeCobalt

Dropdown menu

A list of commands opened from a button, or by a right click on an area.

Examples

Each list's commands under its name, with the one that removes it last.
  • Reading list12 items
  • Q3 13F filings8 items
  • Climate risk papers21 items
Opened by right clickRight-click or long-press the card, or use its More button, and the same rows open.
Reading list
12 articles, 3 unread

Saved from the browser and the phone, newest first.

Variants

Reading list
Q3 13F filings
Climate risk papers
DestructiveA command that removes something, in red on a 10 percent wash when highlighted.

States

Reading list

10 of 10 lists used. Delete one to duplicate this list.

DisabledA disabled row is dimmed and skipped by the arrow keys.

Usage

Use it when

  • A thing on screen has 2 to 5 commands and no room to show them as buttons: a card, a row, a header.
  • You choose one command and the menu goes away.
  • An area, a card or a row has commands you expect behind a right click or a long press, and the same commands are already behind its More button. Wrap it in a ContextMenu.

Use something else when

  • You pick a value that stays shown, such as a sort order or a filter. Use Select or SegmentedControl instead.
  • The content is a form, a list with its own focus, or anything you read before acting. Use Popover instead.
  • The choice is the one next step. Use Button instead, in the view.

Rules

General

Content

Avoid

Limits

Install

npx shadcn@latest add https://kaanarici.com/r/cobalt/dropdown-menu.json https://kaanarici.com/r/cobalt/context-menu.json
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuGroup, DropdownMenuLabel, DropdownMenuItem, DropdownMenuCheckboxItem, DropdownMenuSeparator, menuItemClasses } from "@/components/cobalt/ui/dropdown-menu"
import { ContextMenu, ContextMenuTrigger, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuSeparator } from "@/components/cobalt/ui/context-menu"