@mshafiqyajid/react-dropdown-menu
Headless dropdown menu hook and styled component. Items with icons and dividers, four placements, full keyboard navigation, portal positioning, ARIA-compliant.
Playground #
Props
TSX
import { DropdownMenuStyled } from "@mshafiqyajid/react-dropdown-menu/styled";
import "@mshafiqyajid/react-dropdown-menu/styles.css";
<DropdownMenuStyled
items={items}
/>Install #
npm install @mshafiqyajid/react-dropdown-menu Quick start #
import { DropdownMenuStyled } from "@mshafiqyajid/react-dropdown-menu/styled";
import "@mshafiqyajid/react-dropdown-menu/styles.css";
<DropdownMenuStyled
trigger={<button>Actions ▾</button>}
items={[
{ label: "Edit", onClick: () => handleEdit() },
{ label: "Copy", onClick: () => handleCopy() },
{ label: "", divider: true },
{ label: "Delete", onClick: () => handleDelete() },
]}
/> API #
| Prop | Type | Default | Description |
|---|---|---|---|
| trigger | ReactNode | — | The trigger element |
| items | DropdownMenuItem[] | — | Array of { label, onClick?, icon?, disabled?, divider? } |
| placement | "bottom-start" | "bottom-end" | "top-start" | "top-end" | "bottom-start" | Menu position |
| size | "sm" | "md" | "lg" | "md" | Item size |