GooseUI

Components

Dropdown Menu


Dropdown Menu presents actions in a compact popover. It opens from a button and closes when an action is chosen or the user clicks outside. Arrow keys, Home and End move between actions. Escape closes the menu and returns focus to the trigger.

Browser support

Popover

Displays content in the browser top layer.

Your browser:
Anchor positioning

Positions content by its trigger; JavaScript positions it when anchors are unavailable.

Your browser:
@starting-style

Animates entry when supported; otherwise content appears immediately.

Your browser:

Preview

Installation

npx shadcn@latest add @gooseui/dropdown-menu
pnpm dlx shadcn@latest add @gooseui/dropdown-menu
yarn dlx shadcn@latest add @gooseui/dropdown-menu
bunx --bun shadcn@latest add @gooseui/dropdown-menu

Usage

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

<DropdownMenu>
  <DropdownMenuTrigger asChild><button>Actions</button></DropdownMenuTrigger>
  <DropdownMenuContent align="end">
    <DropdownMenuItem onSelect={() => console.log("Edit")}>Edit</DropdownMenuItem>
  </DropdownMenuContent>
</DropdownMenu>

Examples

Position

The menu opens on the chosen side of the trigger. When there is not enough room, it flips to the opposite side on its own.

<DropdownMenuContent side="top">...</DropdownMenuContent>
<DropdownMenuContent side="bottom" align="end">...</DropdownMenuContent>

Language switcher

Menu items can be links. Ready-made version: Language Switcher

<DropdownMenu>
  <DropdownMenuTrigger aria-label="Language">EN</DropdownMenuTrigger>
  <DropdownMenuContent align="end">
    <a role="menuitem" tabIndex={-1} href="/" aria-current="true">English</a>
    <a role="menuitem" tabIndex={-1} href="/ru">Русский</a>
  </DropdownMenuContent>
</DropdownMenu>

Props

PropTypeDefaultDescription
side"top" | "bottom" | "left" | "right""bottom"Preferred side of the trigger. Flips to the opposite side when there is no room.
align"start" | "center" | "end""center"Alignment along the trigger.
sideOffsetnumber4Distance from the trigger in pixels.
asChildbooleanfalseUse the child as the trigger.
onSelect(event) => void—Runs on selection; preventDefault keeps the menu open.
disabledbooleanfalseDisable this action.