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.jsonGuidelines
- Destructive items last, after a separator, with
danger. - Without
triggerit renders the menu panel alone (for context menus you position).
Props
| Prop | Type | Required |
|---|---|---|
items | Array<'-' | { separator: true } | { section: string } | { label: React.ReactNode; icon?: string; shortcut?: string; danger?: boolean; disabled?: boolean; onSelect?: () => void }> | Yes |
trigger | React.ReactElement | No |
open | boolean | No |
defaultOpen | boolean | No |
onOpenChange | (open: boolean) => void | No |
align | 'start' | 'end' | No |
label | string | No |
className | string | No |