Skip to content

Now in the official shadcn registry directory.

Start free

Dropdown Menu

A keyboard-navigable menu with danger items, checkbox items, radio groups, submenus and shortcuts.

overlaynavigation
A free styled version is available

Installation

Run the following command

npx shadcn@latest add @ai2/dropdown-menu

Dependencies, the @ai2/tokens theme and the component file are installed together.

Usage

TS
import { Button } from "@/components/ui/button"
import {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuItem,
  DropdownMenuSeparator,
  DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu"

<DropdownMenu>
  <DropdownMenuTrigger asChild>
    <Button variant="outline">Open menu</Button>
  </DropdownMenuTrigger>
  <DropdownMenuContent>
    <DropdownMenuItem>Settings</DropdownMenuItem>
    <DropdownMenuSeparator />
    <DropdownMenuItem variant="danger">Sign out</DropdownMenuItem>
  </DropdownMenuContent>
</DropdownMenu>

Wrap any element with DropdownMenuTrigger asChild to make it the trigger. The menu portals to the body, animates from the trigger side and is fully keyboard navigable.

Examples

Item variants and states

Both item variants in one menu: default for plain actions and variant="danger" for destructive ones, plus the inset and disabled states and a right-aligned DropdownMenuShortcut.

Checkbox items

Control the checkmark with checked and onCheckedChange from radix.

Radio group

Props

All parts forward their radix DropdownMenu props: onSelect and disabled on items, open / onOpenChange on the root. The ai2-specific props:

PropTypeDefaultDescription
variant"default" | "danger""default"danger colors the item (and its icons) with the danger tone for destructive actions.
insetboolean-Adds left padding so plain items align with checkbox and radio items. Also available on DropdownMenuLabel and DropdownMenuSubTrigger.
PropTypeDefaultDescription
sideOffsetnumber6Distance in pixels between the trigger and the menu.

ai2 Dropdown Menu: a complete action menu for React

The ai2 Dropdown Menu is a shadcn-compatible dropdown menu component for React, built on the radix-ui DropdownMenu primitive and styled with Tailwind CSS v4. It covers the whole menu vocabulary in one install: plain actions, a danger variant for destructive items, checkbox items, radio groups, nested submenus, labels, separators and right-aligned shortcut hints.

Because it ships through the shadcn registry format, you install it with one CLI command, an MCP agent, or a copy-paste, and the source lands in your own project. You own the file; there is no runtime dependency on ai2 itself. The live example above is the exact component you get.

What is the ai2 Dropdown Menu?

It is a fourteen-part composition around DropdownMenu, DropdownMenuTrigger and DropdownMenuContent, with DropdownMenuItem, DropdownMenuCheckboxItem, DropdownMenuRadioGroup and DropdownMenuRadioItem for entries, plus label, separator, shortcut and the DropdownMenuSub trio for nesting. The anatomy matches shadcn/ui exactly, so existing snippets and AI agents keep working.

On top of the radix API, items add two ai2 props: variant, where danger colors the item and its icons with the danger tone, and inset, which aligns plain items with checkbox and radio rows. The content portals to the body, animates from the trigger side and caps its height to the available viewport space.

Why use it

  • Accessible by construction: The radix-ui DropdownMenu primitive handles menu roles, typeahead, focus management and dismissal: arrow keys move, Enter selects, Escape closes and focus returns to the trigger.
  • Danger items built in: variant="danger" styles destructive actions like Delete or Sign out with the danger token, including their icons and a soft danger highlight on focus, no custom classes needed.
  • Stateful items included: Checkbox items with check indicators and exclusive radio groups with dot indicators ship in the same file, so view toggles and position pickers need no extra components.
  • Submenus that behave: DropdownMenuSub gives hover and keyboard-openable nested menus with the correct aria wiring and a chevron indicator, which hand-rolled menus rarely get right.
  • Agent-readable metadata: The registry item describes its parts and intended use in plain words, so an MCP agent can find, inspect and install it without guessing.

Features

  • shadcn registry install: One command adds the component, its dependencies and the @ai2/tokens theme to your project.
  • Viewport-aware content: The menu caps its height to the radix available-height variable and scrolls internally, so long menus never run off screen.
  • Origin-aware animation: Open and close fade and zoom from the trigger side using the radix transform-origin variable, and item highlights run on the --motion-fast token.
  • Labels, separators and shortcuts: DropdownMenuLabel titles a section, DropdownMenuSeparator splits groups, and DropdownMenuShortcut right-aligns a keyboard hint inside any item.
  • Inset alignment: The inset prop on items, labels and sub-triggers adds left padding so mixed menus with and without indicators stay on one text edge.
  • Data attributes for styling: Every part exposes data-slot, items expose data-variant, and radix adds data-state and data-disabled, so any state is targetable from CSS.

Production tips

  • Use asChild on the trigger: DropdownMenuTrigger asChild turns your own Button or icon button into the trigger without nesting two buttons in the DOM.
  • Put danger items last: Separate destructive actions with a DropdownMenuSeparator and keep them at the bottom with variant="danger", so muscle memory never lands on Delete.
  • Menus act, they do not navigate forms: Use onSelect for actions. For picking a value in a form, an ai2 Select or Combobox is the right control; radio items fit view preferences, not form data.
  • Keep submenus shallow: One level of nesting is scannable; two is a maze. If a submenu grows past roughly seven items, promote it to its own dialog or page.
  • Mind checkbox item dismissal: By default the menu closes when a checkbox item is toggled. For multi-toggle panels, call event.preventDefault() in onSelect to keep it open.

Works with the rest of ai2

The classic recipe is an ai2 Button trigger, an ai2 Avatar for account menus, and ai2 Kbd caps inside shortcut hints. In data tables, pair it with the ai2 Table for per-row action menus.

Choose the right overlay for the job: the ai2 Popover hosts arbitrary content rather than menu items, and the ai2 Dialog handles the confirmation a danger item usually leads to. All of them share one token source and the same popover surface styling.

FAQs

Get new components in your inbox

Component drops, new themes and release notes. No spam, and you can unsubscribe from any email.

© 2026 ai2 design system · MIT licensed · Built with its own components