Skip to content

Dropdown Menu

A menu of actions that opens from a trigger.

Base UI1.7 kB gzipSource Registry JSON

DropdownMenu playground

Props

side
align

Installation

npx shadcn@latest add https://sproutboat.com/ikada/r/dropdown-menu.json

The CLI writes components/ikada/dropdown-menu.tsx and merges the ikada theme into your CSS. Or take it from the package: import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuCheckboxItem, DropdownMenuRadioItem, DropdownMenuLabel, DropdownMenuSeparator } from "@sproutboat/ikada";

Usage

import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuCheckboxItem, DropdownMenuRadioItem, DropdownMenuLabel, DropdownMenuSeparator } from "@/components/ikada/dropdown-menu";

<DropdownMenu>
  <DropdownMenuTrigger render={<Button>Actions</Button>} />
  <DropdownMenuContent>
    <DropdownMenuItem>Rename</DropdownMenuItem>
    <DropdownMenuItem>Duplicate</DropdownMenuItem>
    <DropdownMenuSeparator />
    <DropdownMenuItem destructive>Delete</DropdownMenuItem>
  </DropdownMenuContent>
</DropdownMenu>

Examples

Menu

Arrow keys move, Enter picks, Escape closes. A disabled item is skipped; destructive ones sit last, after a separator.

Destructive item

Radio and checkbox items

With either kind present every item shares one gutter, so labels line up whether or not a row shows a check.

Props

DropdownMenuContentProps
PropTypeDescription
classNamestringClasses merged onto the root element, after ikada's own.
sideSideWhich side of the trigger the popup opens on. Flips when there is no room. Default `bottom`.
alignAlignHow the popup lines up with the trigger along that side. Default `end`.
styleCSSProperties | ((state: MenuPopupState) => CSSProperties)Style applied to the element, or a function that returns a style object based on the component's state.
renderReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, MenuPopupState>Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.

Also takes every prop of Omit<ComponentProps<typeof Menu.Popup>, "className">.

DropdownMenuItemProps
PropTypeDescription
classNamestringClasses merged onto the root element, after ikada's own.
destructivebooleanDestructive items use the danger text color. Default `false`.
styleCSSProperties | ((state: MenuItemState) => CSSProperties)Style applied to the element, or a function that returns a style object based on the component's state.
renderReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, MenuItemState>Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.

Also takes every prop of Omit<ComponentProps<typeof Menu.Item>, "className">.

DropdownMenuCheckboxItemProps
PropTypeDescription
styleCSSProperties | ((state: MenuCheckboxItemState) => CSSProperties)Style applied to the element, or a function that returns a style object based on the component's state.
renderReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, MenuCheckboxItemState>Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.
classNamestringClasses merged onto the root element, after ikada's own.
DropdownMenuRadioItemProps
PropTypeDescription
styleCSSProperties | ((state: MenuRadioItemState) => CSSProperties)Style applied to the element, or a function that returns a style object based on the component's state.
renderReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, MenuRadioItemState>Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.
classNamestringClasses merged onto the root element, after ikada's own.
DropdownMenuLabelProps
PropTypeDescription
styleCSSProperties | ((state: MenuGroupLabelState) => CSSProperties)Style applied to the element, or a function that returns a style object based on the component's state.
renderReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, MenuGroupLabelState>Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.
classNamestringClasses merged onto the root element, after ikada's own.
DropdownMenuSeparatorProps
PropTypeDescription
styleCSSProperties | ((state: SeparatorState) => CSSProperties)Style applied to the element, or a function that returns a style object based on the component's state.
renderReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, SeparatorState>Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.
classNamestringClasses merged onto the root element, after ikada's own.

Source: src/components/dropdown-menu.tsx