Documentation
Dropdown

Dropdown

Example

import { Dropdown, IconButton } from '@i4o/catalystui'
import {
	ExitIcon,
	ExternalLinkIcon,
	FileIcon,
	GearIcon,
	HamburgerMenuIcon,
	InfoCircledIcon,
} from '@radix-ui/react-icons'
 
export default () => {
	const dropdownItems = [
		{
			label: 'New',
			icon: <FileIcon />,
			submenu: [
				{
					label: 'File',
					icon: <FileIcon />,
					onClick: () => console.log('File'),
					shortcut: 'Ctrl+N',
				},
				{
					label: 'Folder',
					icon: <FileIcon />,
					onClick: () => console.log('Folder'),
					shortcut: 'Ctrl+Shift+N',
				},
			],
			type: 'submenu',
		},
		{
			label: 'View Post',
			icon: <ExternalLinkIcon />,
			onClick: () => console.log('View Post'),
			shortcut: 'Ctrl+Shift+V',
		},
		{
			type: 'separator',
		},
		{
			label: 'Settings',
			icon: <GearIcon />,
			onClick: () => console.log('Settings'),
			shortcut: 'Ctrl+,',
		},
		{
			type: 'separator',
		},
		{
			label: 'About',
			icon: <InfoCircledIcon />,
			onClick: () => console.log('About'),
		},
		{
			label: 'Exit',
			icon: <ExitIcon />,
			onClick: () => console.log('Logout'),
			shortcut: 'Ctrl+Q',
		},
	]
 
	return (
		<Dropdown
			align='start'
			items={dropdownItems}
			trigger={<IconButton icon={<HamburgerMenuIcon />} />}
		/>
	)
}

Props

NameTypeDefaultDescription
align'start' | 'center' | 'end''start'The alignment of the dropdown menu.
itemsDropdownItem[][]The items to display in the dropdown menu.
triggerReactNodenullThe trigger element.

DropdownItem

NameTypeDefaultDescription
type'submenu' | 'separator' | 'item''item'Type of the dropdown menu item.
labelstring | ReactNode''Label to display for the item.
iconReactNode-Icon to display for the item.
submenuDropdownItem[][]The items to display as the submenu for the item.
linkstring-URL to open on click when type is item.
onSelect() => void-Function to call when type is item.
shortcutstring-Keyboard shortcut to display when type is item. Calling the onSelect function is not handled. User has to handle it on their own.