Dropdown Menu

DropdownMenu is a floating menu anchored to a trigger that presents a short list of contextual actions or commands.

tsx
import { RiArrowDownSLine, RiDeleteBinLine, RiFileCopyLine, RiPencilLine, RiShareLine } from '@remixicon/react';
import { Button } from '@/components/ui/wideset/button/Button';
import { DropdownMenu } from '@/components/ui/wideset/dropdown/DropdownMenu';
import { ListItem } from '@/components/ui/wideset/list-item/ListItem';

<DropdownMenu>
  <DropdownMenu.Trigger asChild>
    <Button variant="secondary" preset="border">
      Actions
      <Button.Icon icon={RiArrowDownSLine} />
    </Button>
  </DropdownMenu.Trigger>
  <DropdownMenu.Content align="start">
    <DropdownMenu.Item>
      <ListItem.Prefix>
        <RiPencilLine className="size-ws-9" />
      </ListItem.Prefix>
      <ListItem.Content>
        <ListItem.Label>Rename</ListItem.Label>
      </ListItem.Content>
    </DropdownMenu.Item>
    <DropdownMenu.Item>
      <ListItem.Prefix>
        <RiFileCopyLine className="size-ws-9" />
      </ListItem.Prefix>
      <ListItem.Content>
        <ListItem.Label>Duplicate</ListItem.Label>
      </ListItem.Content>
    </DropdownMenu.Item>
    <DropdownMenu.Item>
      <ListItem.Prefix>
        <RiShareLine className="size-ws-9" />
      </ListItem.Prefix>
      <ListItem.Content>
        <ListItem.Label>Share</ListItem.Label>
      </ListItem.Content>
    </DropdownMenu.Item>
    <DropdownMenu.Separator />
    <DropdownMenu.Item variant="danger">
      <ListItem.Prefix>
        <RiDeleteBinLine className="size-ws-9" />
      </ListItem.Prefix>
      <ListItem.Content>
        <ListItem.Label>Delete</ListItem.Label>
      </ListItem.Content>
    </DropdownMenu.Item>
  </DropdownMenu.Content>
</DropdownMenu>

Installation

pnpm dlx wideset add dropdown-menu

Copies the component and any Wideset components it uses into your project.

Examples

Variants

variant="danger" paints an item for an action that destroys or signs out. Keep it to one per menu, last, behind a DropdownMenu.Separator, so it is never the item the pointer lands on by accident. Arrow keys move through the items and Enter picks one, whatever their variant.

tsx
import { RiArrowDownSLine, RiDeleteBinLine, RiDownloadLine, RiStarLine } from '@remixicon/react';
import { Button } from '@/components/ui/wideset/button/Button';
import { DropdownMenu } from '@/components/ui/wideset/dropdown/DropdownMenu';
import { ListItem } from '@/components/ui/wideset/list-item/ListItem';

export default function DropdownMenuVariants() {
  return (
    <DropdownMenu>
      <DropdownMenu.Trigger asChild>
        <Button variant="secondary" preset="border">
          Invoice #1042
          <Button.Icon icon={RiArrowDownSLine} />
        </Button>
      </DropdownMenu.Trigger>
      <DropdownMenu.Content align="start">
        <DropdownMenu.Item>
          <ListItem.Prefix>
            <RiDownloadLine className="size-ws-9" />
          </ListItem.Prefix>
          <ListItem.Content>
            <ListItem.Label>Download PDF</ListItem.Label>
          </ListItem.Content>
        </DropdownMenu.Item>
        <DropdownMenu.Item>
          <ListItem.Prefix>
            <RiStarLine className="size-ws-9" />
          </ListItem.Prefix>
          <ListItem.Content>
            <ListItem.Label>Add to favourites</ListItem.Label>
          </ListItem.Content>
        </DropdownMenu.Item>
        <DropdownMenu.Separator />
        <DropdownMenu.Item variant="danger">
          <ListItem.Prefix>
            <RiDeleteBinLine className="size-ws-9" />
          </ListItem.Prefix>
          <ListItem.Content>
            <ListItem.Label>Delete invoice</ListItem.Label>
          </ListItem.Content>
        </DropdownMenu.Item>
      </DropdownMenu.Content>
    </DropdownMenu>
  );
}

States

A disabled item stays in the menu, dimmed, and the arrow keys skip it. Keep it only when the user can tell why it is unavailable (say so in the label); otherwise leave the item out. DropdownMenu.Label titles a group of items and cannot be focused or picked.

tsx
import { RiArrowDownSLine, RiBarChartLine, RiQuestionLine, RiUserLine } from '@remixicon/react';
import { Button } from '@/components/ui/wideset/button/Button';
import { DropdownMenu } from '@/components/ui/wideset/dropdown/DropdownMenu';
import { ListItem } from '@/components/ui/wideset/list-item/ListItem';

export default function DropdownMenuStates() {
  return (
    <DropdownMenu>
      <DropdownMenu.Trigger asChild>
        <Button variant="secondary" preset="border">
          Account
          <Button.Icon icon={RiArrowDownSLine} />
        </Button>
      </DropdownMenu.Trigger>
      <DropdownMenu.Content align="start">
        <DropdownMenu.Label>Account</DropdownMenu.Label>
        <DropdownMenu.Item>
          <ListItem.Prefix>
            <RiUserLine className="size-ws-9" />
          </ListItem.Prefix>
          <ListItem.Content>
            <ListItem.Label>Profile</ListItem.Label>
          </ListItem.Content>
        </DropdownMenu.Item>
        <DropdownMenu.Item disabled>
          <ListItem.Prefix>
            <RiBarChartLine className="size-ws-9" />
          </ListItem.Prefix>
          <ListItem.Content>
            <ListItem.Label>Reports (coming soon)</ListItem.Label>
          </ListItem.Content>
        </DropdownMenu.Item>
        <DropdownMenu.Separator />
        <DropdownMenu.Label>Support</DropdownMenu.Label>
        <DropdownMenu.Item>
          <ListItem.Prefix>
            <RiQuestionLine className="size-ws-9" />
          </ListItem.Prefix>
          <ListItem.Content>
            <ListItem.Label>Help centre</ListItem.Label>
          </ListItem.Content>
        </DropdownMenu.Item>
      </DropdownMenu.Content>
    </DropdownMenu>
  );
}

Submenus

Group related choices under one menu item, such as the sort order for a file list.

tsx
import { RiArrowDownSLine } from '@remixicon/react';
import { Button } from '@/components/ui/wideset/button/Button';
import { DropdownMenu } from '@/components/ui/wideset/dropdown/DropdownMenu';
import { useState } from 'react';

export default function DropdownMenuSubmenus() {
  const [sortBy, setSortBy] = useState('name');

  return (
    <DropdownMenu>
      <DropdownMenu.Trigger asChild>
        <Button variant="secondary" preset="border">
          File options
          <Button.Icon icon={RiArrowDownSLine} />
        </Button>
      </DropdownMenu.Trigger>
      <DropdownMenu.Content align="start">
        <DropdownMenu.Sub>
          <DropdownMenu.SubTrigger>Sort by</DropdownMenu.SubTrigger>
          <DropdownMenu.SubContent>
            <DropdownMenu.RadioGroup
              aria-label="Sort files by"
              value={sortBy}
              onValueChange={setSortBy}
            >
              <DropdownMenu.RadioItem value="name">Name</DropdownMenu.RadioItem>
              <DropdownMenu.RadioItem value="modified">Last modified</DropdownMenu.RadioItem>
            </DropdownMenu.RadioGroup>
          </DropdownMenu.SubContent>
        </DropdownMenu.Sub>
        <DropdownMenu.Separator />
        <DropdownMenu.Item disabled={sortBy === 'name'} onSelect={() => setSortBy('name')}>
          Reset sort order
        </DropdownMenu.Item>
      </DropdownMenu.Content>
    </DropdownMenu>
  );
}

API reference

DropdownMenu

No props of its ownIt takes its content as children.
Every other prop of Radix DropdownMenu.Root is passed through to it. See Radix DropdownMenu.Root.

DropdownMenu.CheckboxItem

No props of its ownIt takes its content as children.
Every other prop of Radix DropdownMenu.CheckboxItem is passed through to it. See Radix DropdownMenu.CheckboxItem.

DropdownMenu.Content

NameDescriptionDefault
defaultMotion

Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`.

boolean
true
portalContainer

DOM node to portal the content into. Defaults to `document.body`.

Element | DocumentFragment
—
Every other prop of Radix DropdownMenu.Content is passed through to it. See Radix DropdownMenu.Content.

DropdownMenu.Group

No props of its ownIt takes its content as children.
Every other prop of Radix DropdownMenu.Group is passed through to it. See Radix DropdownMenu.Group.

DropdownMenu.ItemIndicator

No props of its ownIt takes its content as children.
Every other prop of Radix DropdownMenu.ItemIndicator is passed through to it. See Radix DropdownMenu.ItemIndicator.

DropdownMenu.Item

NameDescriptionDefault
data-disabled

Applies disabled styling for consumers such as Radix menu items.

boolean
—
data-state

Selection state. The checked state displays a checkmark when enabled.

'checked''unchecked'
—
defaultMotion

Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`.

boolean
true
disabled

Disables the item and applies disabled styling.

boolean
—
shouldDisplayCheckmark

Allows a checkmark to appear for checked items. Defaults to `true`.

boolean
—
variant
'primary''danger'
—
Every other prop of Radix DropdownMenu.Item is passed through to it. See Radix DropdownMenu.Item.

DropdownMenu.Label

NameDescriptionDefault
inset

Indents the label so it aligns with item text in menus that have a leading icon or checkmark slot.

boolean
—
Every other prop of Radix DropdownMenu.Label is passed through to it. See Radix DropdownMenu.Label.

DropdownMenu.Portal

No props of its ownIt takes its content as children.
Every other prop of Radix DropdownMenu.Portal is passed through to it. See Radix DropdownMenu.Portal.

DropdownMenu.RadioGroup

No props of its ownIt takes its content as children.
Every other prop of Radix DropdownMenu.RadioGroup is passed through to it. See Radix DropdownMenu.RadioGroup.

DropdownMenu.RadioItem

No props of its ownIt takes its content as children.
Every other prop of Radix DropdownMenu.RadioItem is passed through to it. See Radix DropdownMenu.RadioItem.

DropdownMenu.Separator

No props of its ownIt takes its content as children.
Every other prop of Radix DropdownMenu.Separator is passed through to it. See Radix DropdownMenu.Separator.

DropdownMenu.SubContent

No props of its ownIt takes its content as children.
Every other prop of Radix DropdownMenu.SubContent is passed through to it. See Radix DropdownMenu.SubContent.

DropdownMenu.SubTrigger

No props of its ownIt takes its content as children.
Every other prop of Radix DropdownMenu.SubTrigger is passed through to it. See Radix DropdownMenu.SubTrigger.

DropdownMenu.Trigger

No props of its ownIt takes its content as children.
Every other prop of Radix DropdownMenu.Trigger is passed through to it. See Radix DropdownMenu.Trigger.

Accessibility

  • Radix gives the menu / menuitem roles, arrow keys, typeahead, Enter and Escape; disabled items are skipped.
  • An icon-only trigger needs an aria-label (IconButton takes it).
  • Focus returns to the trigger after keyboard use.
PartRendersDescription
DropdownMenuRadix DropdownMenu.RootAn anchored menu of contextual actions.
DropdownMenu.CheckboxItemRadix DropdownMenu.CheckboxItemA toggleable choice within the menu.
DropdownMenu.ContentRadix DropdownMenu.ContentThe content surface rendered within `DropdownMenu`.
DropdownMenu.GroupRadix DropdownMenu.GroupA container grouping related items.
DropdownMenu.ItemIndicatorRadix DropdownMenu.ItemIndicatorAn indicator shown for a checked menu item.
DropdownMenu.ItemRadix DropdownMenu.ItemAn individual item within `DropdownMenu`.
DropdownMenu.LabelRadix DropdownMenu.LabelThe text label associated with `DropdownMenu`.
DropdownMenu.PortalRadix DropdownMenu.PortalThe portal destination for floating content.
DropdownMenu.RadioGroupRadix DropdownMenu.RadioGroupA group of mutually exclusive radio options.
DropdownMenu.RadioItemRadix DropdownMenu.RadioItemA choice within a radio group.
DropdownMenu.SeparatorRadix DropdownMenu.SeparatorA visual separator between groups of items.
DropdownMenu.SubContentRadix DropdownMenu.SubContentThe panel that displays a submenu's items.
DropdownMenu.SubTriggerRadix DropdownMenu.SubTriggerThe menu row that opens a submenu.
DropdownMenu.TriggerRadix DropdownMenu.TriggerThe control that opens or toggles the associated content.
tsx
import { RiArrowDownSLine, RiDeleteBinLine, RiFileCopyLine, RiPencilLine, RiShareLine } from '@remixicon/react';
import { Button } from '@/components/ui/wideset/button/Button';
import { DropdownMenu } from '@/components/ui/wideset/dropdown/DropdownMenu';
import { ListItem } from '@/components/ui/wideset/list-item/ListItem';

<DropdownMenu>
  <DropdownMenu.Trigger asChild>
    <Button variant="secondary" preset="border">
      Actions
      <Button.Icon icon={RiArrowDownSLine} />
    </Button>
  </DropdownMenu.Trigger>
  <DropdownMenu.Content align="start">
    <DropdownMenu.Item>
      <ListItem.Prefix>
        <RiPencilLine className="size-ws-9" />
      </ListItem.Prefix>
      <ListItem.Content>
        <ListItem.Label>Rename</ListItem.Label>
      </ListItem.Content>
    </DropdownMenu.Item>
    <DropdownMenu.Item>
      <ListItem.Prefix>
        <RiFileCopyLine className="size-ws-9" />
      </ListItem.Prefix>
      <ListItem.Content>
        <ListItem.Label>Duplicate</ListItem.Label>
      </ListItem.Content>
    </DropdownMenu.Item>
    <DropdownMenu.Item>
      <ListItem.Prefix>
        <RiShareLine className="size-ws-9" />
      </ListItem.Prefix>
      <ListItem.Content>
        <ListItem.Label>Share</ListItem.Label>
      </ListItem.Content>
    </DropdownMenu.Item>
    <DropdownMenu.Separator />
    <DropdownMenu.Item variant="danger">
      <ListItem.Prefix>
        <RiDeleteBinLine className="size-ws-9" />
      </ListItem.Prefix>
      <ListItem.Content>
        <ListItem.Label>Delete</ListItem.Label>
      </ListItem.Content>
    </DropdownMenu.Item>
  </DropdownMenu.Content>
</DropdownMenu>

Appearance

Trigger
Align

Content

Icons
Delete item