Primitives for composing menus—such as a set of actions or functions.
import React from 'react';
import { Menu, MenuItem, MenuLabel, MenuSeparator } from '@minddrop/ui';
export const MenuDemo = () => (
<div style={{ width: 240 }}>
<Menu>
<MenuItem
label="Add title"
icon="title"
keyboardShortcut={['Ctrl', 'T']}
/>
<MenuItem
label="Add note"
icon="note"
keyboardShortcut={['Ctrl', 'Shift', 'N']}
/>
<MenuItem hasSubmenu label="Turn into" icon="turn-into" />
<MenuSeparator />
<MenuLabel>Actions</MenuLabel>
<MenuItem
label="Copy link"
icon="link"
keyboardShortcut={['Ctrl', 'Shift', 'C']}
/>
<MenuItem
label="Move to"
icon="arrow-up-right"
keyboardShortcut={['Ctrl', 'Shift', 'M']}
/>
<MenuItem
label="Add to"
icon="inside"
keyboardShortcut={['Ctrl', 'Shift', 'A']}
/>
</Menu>
</div>
);
export default MenuDemo;
Menu components are intended for internal use and do not support any interactions by default. To create a dropdown or context menu, use the DropdownMenu
or ContextMenu
components which build upon these components.
Import the components from the @minddrop/ui
package.
import { Menu, MenuGroup, MenuItem } from '@minddrop/ui';
export default () => {
return (
<Menu>
<MenuItem
label="Add title"
icon="title"
keyboardShortcut={['Ctrl', 'T']}
/>
<MenuItem
label="Add note"
icon="note"
keyboardShortcut={['Ctrl', 'Shift', 'N']}
/>
<MenuItem hasSubmenu label="Turn into" icon="turn-into" />
<MenuSeparator />
<MenuLabel>Actions</MenuLabel>
<MenuItem
label="Copy link"
icon="link"
keyboardShortcut={['Ctrl', 'Shift', 'C']}
/>
<MenuItem
label="Move to"
icon="arrow-up-right"
keyboardShortcut={['Ctrl', 'Shift', 'M']}
/>
<MenuItem
label="Add to"
icon="inside"
keyboardShortcut={['Ctrl', 'Shift', 'A']}
/>
</Menu>
);
};
MenuProps
extends React.HTMLAttributes<HTMLDivElement>
.
Prop | Type | Default |
---|---|---|
children | node |
MenuItemProps
extends React.HTMLAttributes<HTMLDivElement>
.
Prop | Type | Default |
---|---|---|
label* | node | |
icon | IconName | ReactElement | |
hasSubmenu | boolean | |
keyboardShortcut | string[] | |
disabled | boolean |
Used to render a label. It won't be focusable using arrow keys.
MenuLabelProps
extends React.HTMLAttributes<HTMLDivElement>
.
Prop | Type | Default |
---|---|---|
children | node |
Used to visually separate items in the context menu. Does not take any props.
Adheres to the Menu WAI-ARIA design pattern.