Dropdown Menu

A Dropdown Menu component is a UI element that allows users to select an option from a list that appears when the user clicks or hovers over a button or link. This component helps save space on the interface by displaying additional options only when needed. Dropdown menus are commonly used for navigation, settings, or forms, enabling users to choose from multiple choices in a clean and organized manner.
# Demo
# Menu Item Attributes
NameTypeDefaultDetails
classNamestring' 'You can customise by passing tailwind classes.
iconClassNamestring' 'You can customise by passing tailwind classes.
titleClassNamestring' 'You can customise by passing tailwind classes.
shortcutClassNamestring' 'You can customise by passing tailwind classes.
titlestringRequiredYou can pass title for menu item.
shortcutstring' 'You can pass shortcut key for menu item.
iconReactNodeRequiredYou can pass icon for menu item.
separatorbooleanfalseYou can pass separator for menu item.
onClick() => voidYou can get callback when menu item clicked.
# Nested Menu Attributes
NameTypeDefaultDetails
classNamestring' 'You can customise by passing tailwind classes.
triggerClassNamestring' 'You can customise by passing tailwind classes.
sizeMenuSizeMenuSize.MDYou can pass size of the menu.
triggerstring | ReactNodeRequiredYou can pass trigger to menu.
childrenstring | ReactNodeRequiredYou can pass menu content as children.
# Attributes
NameTypeDefaultDetails
classNamestring' 'You can customise by passing tailwind classes.
titleClassNamestring' 'You can customise by passing tailwind classes.
triggerClassNamestring' 'You can customise by passing tailwind classes.
titlestring' 'You can pass title for menu.
sizeMenuSizeMenuSize.MDYou can pass size of the menu.
sidetop | bottom | right | leftbottomYou can pass side to menu.
alignstart | end | centerendYou can pass align to menu.
triggerstring | ReactNodeRequiredYou can pass trigger to menu.
childrenstring | ReactNodeRequiredYou 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;