Put the most common action first and separate destructive actions at the end.
Label, shortcuts and a disabled item
Icon trigger
An icon-only trigger needs an aria-label.
Checkbox items
A checkbox item closes the menu when chosen. Call event.preventDefault() in onSelect to keep it open while the user toggles several options.
Radio items
Submenu
Searchable
searchable adds a search field at the top. The component does not filter: keep the query with onSearchChange and render only the matching items.
Content
Start each item with a verb: “Duplicar tarefa”, “Reatribuir revisor”.
Use sentence case and keep labels under about 30 characters.
Use the same label as the dialog or page the item leads to.
Group related items and separate groups with a DropdownMenuSeparator. Put destructive actions last.
Disable an item instead of hiding it when the action exists but is not available now.
Do and don’t
DoGroup related actions and put the destructive one last, after a separator.
Don'tDon't mix the destructive action with the others, or put it first. It is one slip away.
Accessibility
Built on Radix Dropdown Menu. The trigger has aria-haspopup="menu" and aria-expanded. The popup has role="menu" and items have menuitem, menuitemcheckbox or menuitemradio, with aria-checked on the last two.
Keyboard: Enter, Space or ArrowDown on the trigger opens the menu. ArrowUp and ArrowDown move, Home and End jump, typing letters jumps to a matching item, Enter or Space chooses, ArrowRight opens a submenu, ArrowLeft closes it and Escape closes the menu. Focus returns to the trigger.
Menu items are 44px tall, above the 24px minimum hit target.
Disabled items stay in the menu, are skipped by arrow keys and carry aria-disabled.
The trigger needs an accessible name. An icon-only trigger needs aria-label.
While open, the menu is modal: the page behind is inert and pointer-events are disabled. Pass modal={false} to change it.
Code
import { Button } from "@repo/ui/button";import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger,} from "@repo/ui/dropdown-menu";<DropdownMenu> <DropdownMenuTrigger asChild> <Button variant="secondary">Ações da tarefa</Button> </DropdownMenuTrigger> <DropdownMenuContent align="start"> <DropdownMenuItem onSelect={handleSend}> Enviar para revisão </DropdownMenuItem> <DropdownMenuItem onSelect={handleDuplicate}> Duplicar tarefa </DropdownMenuItem> <DropdownMenuSeparator /> <DropdownMenuItem onSelect={handleDelete}>Excluir tarefa</DropdownMenuItem> </DropdownMenuContent></DropdownMenu>;
Props
DropdownMenu
Prop
Type
Default
Description
defaultOpen
boolean
false
Initial open state when the menu is uncontrolled
modal
boolean
true
Blocks interaction with the rest of the page while open
onOpenChange
(open: boolean) => void
—
Called when the menu opens or closes
open
boolean
—
Controlled open state
DropdownMenuContent
Prop
Type
Default
Description
align
"start" | "center" | "end"
"center"
Alignment against the trigger.
side
"top" | "right" | "bottom" | "left"
"bottom"
Preferred side. The menu flips when there is no room.
sideOffset
number
4
Distance from the trigger in pixels.
searchable
boolean
false
Renders a search field above the items.
searchPlaceholder
string
"Pesquisar..."
Placeholder of the search field. Pass translated copy from the app.
onSearchChange
(value: string) => void
—
Called with the query when the search field changes. The component does not filter the items.
container
HTMLElement | null
—
Element to render the portal into. Defaults to the document body.
DropdownMenuItem
Prop
Type
Default
Description
onSelect
(event: Event) => void
—
Called when the item is chosen. The menu closes afterwards unless you call `event.preventDefault()`.
disabled
boolean
false
Prevents choosing the item.
inset
boolean
false
Adds left padding to align with items that have an indicator. Also on DropdownMenuLabel and DropdownMenuSubTrigger.
asChild
boolean
false
Renders the child element, for example a link, instead of a div.
DropdownMenuCheckboxItem
Prop
Type
Default
Description
checked
boolean | 'indeterminate'
—
Controlled checked state.
onCheckedChange
(checked: boolean) => void
—
Called when the user toggles the item.
DropdownMenuRadioGroup, DropdownMenuRadioItem
Prop
Type
Default
Description
value
string
—
On DropdownMenuRadioGroup: the selected value. On DropdownMenuRadioItem: the value of the option.
onValueChange
(value: string) => void
—
On DropdownMenuRadioGroup: called when the user picks an option.
DropdownMenuSubContent
Prop
Type
Default
Description
container
HTMLElement | null
—
Element to render the submenu portal into.
Known issues
Issue
Effect
searchPlaceholder defaults to the Portuguese string "Pesquisar...".
The package should stay free of app copy. An app that forgets the prop shows Portuguese in every locale.
The search field calls stopPropagation on every keydown.
Arrow keys typed in the field never reach the menu, so they do not move focus to the items.
Disabled items use data-[disabled]:opacity-50.
The repository avoids opacity-based disabled states, and the label contrast drops below the AA minimum.
The popup shadow is the hardcoded shadow-[0px_25px_25px_rgba(0,0,0,0.15)].
A raw color value outside the token system, and translucent.
There is no destructive item style.
“Excluir” looks like any other item, so apps tell it apart only by position and a separator.
Items and labels use raw text-sm and text-xs classes instead of Typography.