DocsComponentsTemplatesThemesGitHub

Menu

Dropdown or context menu on strong glass; keyboard navigable.

Code

import * as React from 'react';
import { IconButton, Menu } from '@fruit-labs/design';

export default function Demo() {
  return (
    <div
      style={{
        minHeight: 280,
      }}
    >
      <Menu
        defaultOpen
        label="Actions"
        trigger={<IconButton icon="ellipsis" label="More actions" />}
        items={[
          {
            label: 'Copy',
            icon: 'copy',
            shortcut: '⌘C',
          },
          {
            label: 'Share…',
            icon: 'share',
          },
          {
            label: 'Favorite',
            icon: 'star',
          },
          '-',
          {
            label: 'Delete',
            icon: 'trash',
            danger: true,
          },
        ]}
      />
    </div>
  );
}

Install

From npm:

npm install @fruit-labs/design

import { Menu } from '@fruit-labs/design';

Or copy the TypeScript source into your project:

npx shadcn@latest add https://design.fruitlabs.online/r/menu.json

Guidelines

  • Destructive items last, after a separator, with danger.
  • Without trigger it renders the menu panel alone (for context menus you position).

Props

PropTypeRequired
itemsArray<'-' | { separator: true } | { section: string } | { label: React.ReactNode; icon?: string; shortcut?: string; danger?: boolean; disabled?: boolean; onSelect?: () => void }>Yes
triggerReact.ReactElementNo
openbooleanNo
defaultOpenbooleanNo
onOpenChange(open: boolean) => voidNo
align'start' | 'end'No
labelstringNo
classNamestringNo

Edit this example on GitHub