Menu
Displays a menu to the user — such as a set of actions or functions — triggered by a button.
# Demo
# Menu Attributes
Name | Type | Default | Details |
---|---|---|---|
className | string | ' ' | You can customise by passing tailwind classes. |
titleClassName | string | ' ' | You can customise by passing tailwind classes. |
triggerClassName | string | ' ' | You can customise by passing tailwind classes. |
title | string | ' ' | You can pass title for menu. |
size | MenuSize | MenuSize.MD | You can pass size of the menu. |
side | top | bottom | right | left | bottom | You can pass side to menu. |
align | start | end | center | end | You can pass align to menu. |
trigger | string | ReactNode | Required | You can pass trigger to menu. |
children | string | ReactNode | Required | You can pass menu content as children. |
# Menu Item Attributes
Name | Type | Default | Details |
---|---|---|---|
className | string | ' ' | You can customise by passing tailwind classes. |
iconClassName | string | ' ' | You can customise by passing tailwind classes. |
titleClassName | string | ' ' | You can customise by passing tailwind classes. |
shortcutClassName | string | ' ' | You can customise by passing tailwind classes. |
title | string | Required | You can pass title for menu item. |
shortcut | string | ' ' | You can pass shortcut key for menu item. |
icon | ReactNode | Required | You can pass icon for menu item. |
separator | boolean | false | You can pass separator for menu item. |
onClick | () => void | You can get callback when menu item clicked. |
# Nested Menu Attributes
Name | Type | Default | Details |
---|---|---|---|
className | string | ' ' | You can customise by passing tailwind classes. |
triggerClassName | string | ' ' | You can customise by passing tailwind classes. |
size | MenuSize | MenuSize.MD | You can pass size of the menu. |
trigger | string | ReactNode | Required | You can pass trigger to menu. |
children | string | ReactNode | Required | You can pass menu content as children. |
# Usage
import { NMenu,NMenuItem, MenuSize, NMenuNested, NButton } from 'nayan';
import { User } from 'lucide-react';
const Menu = () => {
return (
<NMenu align="start" title="My Account" size={MenuSize.LG} trigger={<NButton>Show Menu</NButton>}>
<NMenuItem title="Profile" icon={User} shortcut="⌘P" />
<NMenuNested trigger={<NMenuItem title="Share" icon={User} className="p-0" />}>
<NMenuItem title="Facebook" icon={User} shortcut="⌘P" />
<NMenuItem title="Twitter" icon={User} shortcut="⌘P" />
</NMenuNested>
<NMenuItem title="Settings" icon={User} shortcut="⌘P" separator={true} />
<NMenuItem title="Logout" icon={User} shortcut="⌘P" />
</NMenu>
);
};
export default Menu;