EXEPERTAI LAB

Research alpha

Time Machine
EXEPERTAI LAB
GALLERY / COLLECTION
← Browse Astryx gallery
DropdownMenu·component·@astryxdesign/core

Dropdown Menu Item

Helper component for custom item rendering with consistent styling.

Open in Playground @astryxdesign/core/DropdownMenu

Showcases and examples

2 documented examples

Dropdown Menu Item

Dropdown menu with custom-rendered items using DropdownMenuItem for icons and descriptions.

Preview loads on approachPreview loads on approach
Exact source · dropdown-menu-item-showcase
// Copyright (c) Meta Platforms, Inc. and affiliates.

'use client';

import {DropdownMenu, DropdownMenuItem} from '@astryxdesign/core/DropdownMenu';

const PencilIcon = (props: React.SVGProps<SVGSVGElement>) => (
  <svg
    viewBox="0 0 24 24"
    fill="none"
    stroke="currentColor"
    strokeWidth={1.5}
    strokeLinecap="round"
    strokeLinejoin="round"
    {...props}>
    <path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" />
    <path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z" />
  </svg>
);

const CopyIcon = (props: React.SVGProps<SVGSVGElement>) => (
  <svg
    viewBox="0 0 24 24"
    fill="none"
    stroke="currentColor"
    strokeWidth={1.5}
    strokeLinecap="round"
    strokeLinejoin="round"
    {...props}>
    <rect x="9" y="9" width="13" height="13" rx="2" />
    <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" />
  </svg>
);

const ShareIcon = (props: React.SVGProps<SVGSVGElement>) => (
  <svg
    viewBox="0 0 24 24"
    fill="none"
    stroke="currentColor"
    strokeWidth={1.5}
    strokeLinecap="round"
    strokeLinejoin="round"
    {...props}>
    <circle cx="18" cy="5" r="3" />
    <circle cx="6" cy="12" r="3" />
    <circle cx="18" cy="19" r="3" />
    <line x1="8.59" y1="13.51" x2="15.42" y2="17.49" />
    <line x1="15.41" y1="6.51" x2="8.59" y2="10.49" />
  </svg>
);

const TrashIcon = (props: React.SVGProps<SVGSVGElement>) => (
  <svg
    viewBox="0 0 24 24"
    fill="none"
    stroke="currentColor"
    strokeWidth={1.5}
    strokeLinecap="round"
    strokeLinejoin="round"
    {...props}>
    <polyline points="3 6 5 6 21 6" />
    <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />
  </svg>
);

export default function DropdownMenuItemShowcase() {
  return (
    <DropdownMenu button={{label: 'Actions'}}>
      <DropdownMenuItem
        icon={PencilIcon}
        label="Edit"
        description="Modify this item"
        onClick={() => {}}
      />
      <DropdownMenuItem
        icon={CopyIcon}
        label="Duplicate"
        description="Create a copy"
        onClick={() => {}}
      />
      <DropdownMenuItem icon={ShareIcon} label="Share" onClick={() => {}} />
      <DropdownMenuItem
        icon={TrashIcon}
        label="Delete"
        description="This action cannot be undone"
        onClick={() => {}}
      />
    </DropdownMenu>
  );
}

Usage

Helper component for custom item rendering with consistent styling.

Typed props

PropType and behavior
iconIconType
Icon to display before the label. See astryx docs icons for valid semantic names.
labelReactNode
Primary label text.
descriptionReactNode
Secondary description text displayed below the label.
endContentReactNode
Additional content rendered after the label and description.
hasCloseOnSelectboolean · default true
Whether activating the item closes the menu. Set false for an action that reports its result on the item itself.
variant'default' | 'destructive' · default 'default'
Visual variant. 'destructive' renders the label, description, and icon in the error color for dangerous actions (e.g. Delete).
xstyleStyleXStyles
StyleX styles for layout customization (margins, positioning, sizing). Must be a stylex.create() value: not an inline style object like style={{}}.
refReact.Ref<HTMLElement>
Ref forwarded to the row root, the element carrying role="menuitem". Register the row with an element-keyed observer or overlay.