Navigated to /docs/ui/components/dropdown-menu

DropdownMenu

Trigger-driven menu of contextual commands with menu semantics and keyboard item navigation.

Preview

A live, theme-aware example rendered with the published component.

Loading preview…

Import

Import from the focused entry point below, or use the same named export from @tavojs/ui. Both are public APIs; measure the built application when comparing their bundle cost.

TSX
tsximport { DropdownMenu } from "@tavojs/ui/dropdown-menu";

The component import loads compiled component CSS. Enable tavoUi() for your project theme variables, or import @tavojs/ui/theme.css once for the package default theme. The equivalent CSS-safe component alias is @tavojs/ui/css/dropdown-menu.

When to use

Use it when

Use DropdownMenu for a compact list of actions such as Edit, Duplicate, Archive, or Download.

Choose something else when

Use Popover when the floating surface contains arbitrary content, fields, filters, or explanations rather than a command list.

Examples

These examples include imports and local state where interaction requires it. Render the exported component in a page after completing UI installation. Demo state stays in the mounted component; connect file handling, persistence, and data loading to your application as needed.

DropdownMenu example

TSXCreate: src/components/examples/DropdownMenuExample1.tsx
tsximport { createTavo } from "@tavojs/core";
import { DropdownMenu } from "@tavojs/ui/dropdown-menu";
import { Text } from "@tavojs/ui";

type State = { copies: number };

export const DropdownMenuExample1 = createTavo<Record<string, never>, State>({
  model: () => ({ copies: 0 }),
  view: ({ state, model }) => (
    <>
      <DropdownMenu>
        <DropdownMenu.Trigger>Actions</DropdownMenu.Trigger>
        <DropdownMenu.Content>
          <DropdownMenu.Item onSelect={() => model.set("copies", state.copies + 1)}>Duplicate</DropdownMenu.Item>
          <DropdownMenu.Item href="/settings">Settings</DropdownMenu.Item>
        </DropdownMenu.Content>
      </DropdownMenu>
      <Text role="status">Copies created in this demo: {state.copies}</Text>
    </>
  )
});

Common props and defaults

A curated starting point. The complete TypeScript API below includes additional props and compound member contracts.

PropTypeDefaultDescription
classNamestring

Optional class hook applied to the public root element owned by the component.
openboolean

Configures open for this component.
defaultOpenboolean

Configures defaultOpen for this component.
align"start" | "end"

Configures align for this component.
onClose() => void

Configures onClose for this component.
onOpenChange(open, reason) => void

Configures onOpenChange for this component.

Complete TypeScript API

Import from @tavojs/ui/dropdown-menu. Published exports: DropdownMenu, DropdownMenuClose, DropdownMenuContent, DropdownMenuContentProps, DropdownMenuItem, DropdownMenuItemProps, DropdownMenuProps, DropdownMenuRoot, DropdownMenuTrigger, DropdownMenuTriggerProps.

DropdownMenuProps

PropertyTypeRequiredDescription
childrenChild

No

Inherited children attribute accepted by DropdownMenu.

classNamestring

No

Optional class hook applied to the public root element owned by the component.

sxSx

No

Inherited sx attribute accepted by DropdownMenu.

idstring

No

Inherited id attribute accepted by DropdownMenu.

rolestring

No

Inherited role attribute accepted by DropdownMenu.

styleRecord<string, unknown>

No

Inherited style attribute accepted by DropdownMenu.

titlestring

No

Inherited title attribute accepted by DropdownMenu.

tabIndexnumber

No

Inherited tabIndex attribute accepted by DropdownMenu.

hiddenboolean

No

Inherited hidden attribute accepted by DropdownMenu.

disabledboolean

No

Inherited disabled attribute accepted by DropdownMenu.

onClickTavoEventHandler<MouseEvent>

No

Inherited onClick attribute accepted by DropdownMenu.

onChangeTavoEventHandler<Event>

No

Inherited onChange attribute accepted by DropdownMenu.

onInputTavoEventHandler<Event>

No

Inherited onInput attribute accepted by DropdownMenu.

onKeyDownTavoEventHandler<KeyboardEvent>

No

Inherited onKeyDown attribute accepted by DropdownMenu.

onFocusTavoEventHandler<FocusEvent>

No

Inherited onFocus attribute accepted by DropdownMenu.

onBlurTavoEventHandler<FocusEvent>

No

Inherited onBlur attribute accepted by DropdownMenu.

openboolean

No

Configures open for this component.

defaultOpenboolean

No

Configures defaultOpen for this component.

align"start" | "end"

No

Configures align for this component.

onClose() => void

No

Configures onClose for this component.

onOpenChange(open: boolean, reason: DisclosureOpenChangeReason) => void

No

Configures onOpenChange for this component.

showArrowboolean

No

Inherited showArrow attribute accepted by DropdownMenu.

DropdownMenuTriggerProps

PropertyTypeRequiredDescription
childrenChild

No

Inherited children attribute accepted by DropdownMenu.

classNamestring

No

Optional class hook applied to the public root element owned by the component.

sxSx

No

Inherited sx attribute accepted by DropdownMenu.

idstring

No

Inherited id attribute accepted by DropdownMenu.

rolestring

No

Inherited role attribute accepted by DropdownMenu.

styleRecord<string, unknown>

No

Inherited style attribute accepted by DropdownMenu.

titlestring

No

Inherited title attribute accepted by DropdownMenu.

tabIndexnumber

No

Inherited tabIndex attribute accepted by DropdownMenu.

hiddenboolean

No

Inherited hidden attribute accepted by DropdownMenu.

disabledboolean

No

Inherited disabled attribute accepted by DropdownMenu.

onClickTavoEventHandler<MouseEvent>

No

Inherited onClick attribute accepted by DropdownMenu.

onChangeTavoEventHandler<Event>

No

Inherited onChange attribute accepted by DropdownMenu.

onInputTavoEventHandler<Event>

No

Inherited onInput attribute accepted by DropdownMenu.

onKeyDownTavoEventHandler<KeyboardEvent>

No

Inherited onKeyDown attribute accepted by DropdownMenu.

onFocusTavoEventHandler<FocusEvent>

No

Inherited onFocus attribute accepted by DropdownMenu.

onBlurTavoEventHandler<FocusEvent>

No

Inherited onBlur attribute accepted by DropdownMenu.

labelstring

No

Inherited label attribute accepted by DropdownMenu.

DropdownMenuContentProps

PropertyTypeRequiredDescription
childrenChild

No

Inherited children attribute accepted by DropdownMenu.

classNamestring

No

Optional class hook applied to the public root element owned by the component.

sxSx

No

Inherited sx attribute accepted by DropdownMenu.

idstring

No

Inherited id attribute accepted by DropdownMenu.

rolestring

No

Inherited role attribute accepted by DropdownMenu.

styleRecord<string, unknown>

No

Inherited style attribute accepted by DropdownMenu.

titlestring

No

Inherited title attribute accepted by DropdownMenu.

tabIndexnumber

No

Inherited tabIndex attribute accepted by DropdownMenu.

hiddenboolean

No

Inherited hidden attribute accepted by DropdownMenu.

disabledboolean

No

Inherited disabled attribute accepted by DropdownMenu.

onClickTavoEventHandler<MouseEvent>

No

Inherited onClick attribute accepted by DropdownMenu.

onChangeTavoEventHandler<Event>

No

Inherited onChange attribute accepted by DropdownMenu.

onInputTavoEventHandler<Event>

No

Inherited onInput attribute accepted by DropdownMenu.

onKeyDownTavoEventHandler<KeyboardEvent>

No

Inherited onKeyDown attribute accepted by DropdownMenu.

onFocusTavoEventHandler<FocusEvent>

No

Inherited onFocus attribute accepted by DropdownMenu.

onBlurTavoEventHandler<FocusEvent>

No

Inherited onBlur attribute accepted by DropdownMenu.

useElementDirectiveInput<HTMLDivElement>

No

Inherited use attribute accepted by DropdownMenu.

DropdownMenuItemProps

PropertyTypeRequiredDescription
childrenChild

No

Inherited children attribute accepted by DropdownMenu.

classNamestring

No

Optional class hook applied to the public root element owned by the component.

sxSx

No

Inherited sx attribute accepted by DropdownMenu.

idstring

No

Inherited id attribute accepted by DropdownMenu.

rolestring

No

Inherited role attribute accepted by DropdownMenu.

styleRecord<string, unknown>

No

Inherited style attribute accepted by DropdownMenu.

titlestring

No

Inherited title attribute accepted by DropdownMenu.

tabIndexnumber

No

Inherited tabIndex attribute accepted by DropdownMenu.

hiddenboolean

No

Inherited hidden attribute accepted by DropdownMenu.

disabledboolean

No

Inherited disabled attribute accepted by DropdownMenu.

onClickTavoEventHandler<MouseEvent>

No

Inherited onClick attribute accepted by DropdownMenu.

onChangeTavoEventHandler<Event>

No

Inherited onChange attribute accepted by DropdownMenu.

onInputTavoEventHandler<Event>

No

Inherited onInput attribute accepted by DropdownMenu.

onKeyDownTavoEventHandler<KeyboardEvent>

No

Inherited onKeyDown attribute accepted by DropdownMenu.

onFocusTavoEventHandler<FocusEvent>

No

Inherited onFocus attribute accepted by DropdownMenu.

onBlurTavoEventHandler<FocusEvent>

No

Inherited onBlur attribute accepted by DropdownMenu.

hrefstring

No

Inherited href attribute accepted by DropdownMenu.

closeOnSelectboolean

No

Inherited closeOnSelect attribute accepted by DropdownMenu.

onSelect(event: MouseEvent) => void

No

Inherited onSelect attribute accepted by DropdownMenu.

State ownership and DOM target

ConcernContract
StateUse defaultOpen for browser-owned disclosure state, or open with onOpenChange and update application state after each request.
DOM targetPublic passthrough props target the component root. Treat nested elements and private class names as implementation details.

Anatomy and related components

Public compound members: Root, Trigger, Content, Item, Close

Limitations

Use Popover when the floating surface contains arbitrary content, fields, filters, or explanations rather than a command list.

Use only the documented props, entry points, and compound members. Internal DOM nesting and CSS class names can change without becoming part of the public component contract.

Accessibility

Content uses `role="menu"` and items use `role="menuitem"`.

  • Content uses `role="menu"` and items use `role="menuitem"`.

Component status

ContractCurrent value
Maturitystable
Categoryfeedback
Component import@tavojs/ui/dropdown-menu
Explicit CSS import@tavojs/ui/css/dropdown-menu
PreviewInteractive preview available on this page