Context menu
Secondary actions kept close to the selected object.
A focused list of actions anchored to a trigger.
npx shadcn@latest add @silicon-ui/dropdown-menunpx shadcn@latest add @silicon-ui/dropdown-menuInstall the dependencies.
npm install @radix-ui/react-dropdown-menu lucide-react motionCopy these files into your project. Shared files are skipped if you already have them.
components/silicon-ui/dropdown-menu/dropdown-menu.tsxcomponents/silicon-ui/dropdown-menu/dropdown-menu.module.csscomponents/silicon-ui/lib/menu-highlight.tsx sharedInstall the foundation once per app for the design and motion tokens: npx shadcn@latest add @silicon-ui/silicon-foundation
DropdownMenu| Prop | Type | Default |
|---|---|---|
label*The trigger's text; when it names the current choice, a new label rises in and the trigger springs to its width. | string | — |
items*The actions, in order. | DropdownItem[] | — |
iconAn icon before the trigger's text. | ReactNode | — |
DropdownMenuRootAccepts the props of DropdownMenuProps.
DropdownMenuTrigger| Prop | Type | Default |
|---|---|---|
asChildRender your own trigger (an icon-only Button with an aria-label, an avatar and name) instead of the default one. | boolean | — |
Also accepts the props of ComponentPropsWithoutRef<typeof DropdownPrimitive.Trigger>.
DropdownMenuContent| Prop | Type | Default |
|---|---|---|
sideWhich side of the trigger it opens on (default bottom). | "top" | "right" | "bottom" | "left" | "bottom" |
alignHow it lines up with the trigger (default end). | "start" | "center" | "end" | "end" |
Also accepts the props of ComponentPropsWithoutRef<typeof DropdownPrimitive.Content>.
DropdownMenuItem| Prop | Type | Default |
|---|---|---|
iconA 16px icon before the label. | ReactNode | — |
shortcutA keyboard shortcut hint after the label, such as "⌘D". Shown only; bind the keys yourself. | string | — |
destructiveA destructive action (delete, remove): shown in the danger colour. | boolean | — |
Also accepts the props of ComponentPropsWithoutRef<typeof DropdownPrimitive.Item>.
DropdownMenuCheckboxItem| Prop | Type | Default |
|---|---|---|
shortcutA keyboard shortcut hint after the label. | string | — |
Also accepts the props of ComponentPropsWithoutRef<typeof DropdownPrimitive.CheckboxItem>.
DropdownMenuRadioGroupAccepts the props of MenuRadioGroupProps.
DropdownMenuRadioItem| Prop | Type | Default |
|---|---|---|
iconA 16px icon or avatar before the label; the check shows at the end while this is the current choice. | ReactNode | — |
Also accepts the props of ComponentPropsWithoutRef<typeof DropdownPrimitive.RadioItem>.
DropdownMenuLabelAccepts the props of HTMLAttributes.
DropdownMenuSeparatorAccepts the props of HTMLAttributes.
DropdownMenuGroupAccepts the props of HTMLAttributes.
DropdownMenuSubAccepts the props of DropdownMenuSubProps.
DropdownMenuSubTrigger| Prop | Type | Default |
|---|---|---|
iconA 16px icon before the label. | ReactNode | — |
Also accepts the props of ComponentPropsWithoutRef<typeof DropdownPrimitive.SubTrigger>.
DropdownMenuSubContentAccepts the props of PopperContentProps, MenuSubContentProps, MenuContentImplProps.