Componentpickers1.99 KB gzipZero dependencies
Dropdown Menu
Popup actions menu with keyboard shortcuts and items.
Preview
Live Preview
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add dropdown-menuOr install the full npm package:
npm install bigbulluiUsage
tsx8 lines
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem } from "@/components/ui/dropdown-menu"; <DropdownMenu> <DropdownMenuTrigger><Button variant="outline">Options</Button></DropdownMenuTrigger> <DropdownMenuContent> <DropdownMenuItem shortcut="⌘P">Print</DropdownMenuItem> </DropdownMenuContent></DropdownMenu>Source code
dropdown-menu.tsx + 6 helpersZero third-party dependencies (7 local files shown in tabs below).
tsxdropdown-menu.tsx327 lines
"use client"; import * as React from "react";import { createPortal } from "react-dom";import { cn } from "./lib/utils";import { registerEscapeLayer } from "./lib/focus-trap";import { mergeRefs, useIsMounted } from "./lib/react-compat";import { Slot } from "./lib/slot";import { useControllableState } from "./lib/use-controllable-state";import { useFloating } from "./lib/floating"; interface DropdownMenuContextValue { open: boolean; setOpen: (open: boolean) => void; menuId: string; triggerRef: React.RefObject<HTMLButtonElement | null>; setTriggerEl: (el: HTMLButtonElement | null) => void; setOpenFocusTarget: (target: "first" | "last" | null) => void;Props
Interactive Prop Playground
Tweak parsed AST props below to generate ready-to-paste JSX.
tsx3 lines
import { DropdownMenu } from "@/components/ui/dropdown-menu"; <DropdownMenu />| Prop | Type | Description |
|---|---|---|
| open | boolean | Controlled open visibility state. |
| defaultOpen | boolean | Initial open state when uncontrolled. (Default: false) |
| onOpenChange | (open: boolean) => void | Callback invoked on open change. |
| children | React.ReactNode | Child elements rendered inside the component. |