Dropdown menu

Presents a compact list of actions. Menu roles and arrow-key navigation are built in.

File

Use it for

  • Three or more actions on one object behind a single trigger.
  • Separators to group destructive actions at the end.

Not for

  • Choosing a value; use Select.
  • Navigation links; use NavigationMenu.

Three ways in. They share one source, so the pixels match whichever you pick.

1. Import the package

npm install @noorddev/vlak-react

// once, next to your app's root
import "@noorddev/vlak-react/css";

import { DropdownMenu } from "@noorddev/vlak-react";

Precompiled React and one stylesheet. No compiler to configure. Per-component imports work too: @noorddev/vlak-react/components/dropdown-menu.

2. Vendor the source

npx @noorddev/vlak-cli add dropdown-menu

The StyleX leaf lands in components/vlak/ with its dependencies, for your own compiler to own. See StyleX.

3. Through shadcn

npx shadcn add https://vlak.dev/r/dropdown-menu.json

The same registry item, installed by shadcn's CLI.

CSS only

<link rel="stylesheet" href="node_modules/@noorddev/vlak/css/vlak.css" />

No React. Link vlak.css and use the markup and classes below.

import { DropdownMenu } from "@noorddev/vlak-react";

<DropdownMenu
  label="Actions"
  items={[
    { label: "Rename", onSelect: rename },
    { label: "Duplicate", onSelect: duplicate },
    { separator: true },
    { label: "Delete", onSelect: remove },
    { label: "Archive", disabled: true },
  ]}
/>

DropdownMenu

Action menu with menu semantics and keyboard navigation.

PropTypeDefaultDescription
labelrequiredReactNode
itemsrequiredDropdownMenuItem[]

Also accepts HTMLAttributes<HTMLDivElement>.

KeysDoes
Arrow down, Enter, SpaceOpens the menu on the first item
Arrow upOpens the menu on the last item
Arrow down, Arrow upMoves between items and wraps
Home, EndFirst or last item
Type lettersMoves to the next item starting with them
Enter, SpaceSelects the item and closes
EscapeCloses and returns focus to the trigger
TabCloses and moves on
<div class="rs-menu" role="menu"><button class="rs-menu-item" role="menuitem">Rename</button><button class="rs-menu-item" role="menuitem">Duplicate</button><hr class="rs-menu-sep" /><button class="rs-menu-item" role="menuitem">Delete</button></div>
.rs-menu.rs-dropdown.rs-menu-item.rs-menu-item-active.rs-menu-item-disabled.rs-menu-sep