Skip to main content

Dropdown Menu

v.6.0.0

Installation

yarn add @mercell/dropdown-menu-react

Usage

Using the Dropdown Menu component is as simple as importing it like this.

import { DropdownMenu, DropdownMenuItem } from '@mercell/dropdown-menu-react';
Live Editor
Result

Types, definitions, etc.

DropdownMenuProps
interface DropdownMenuProps {
id: string;
onClose: (evt: any) => void;
anchorRef: RefObject<HTMLElement>;
popperOptions?: PopperOptions;
closeOnClick?: boolean;
} & JSX.IntrinsicElements['div']
Link to Popper Options type
NameTypeDefaultRequiredDescription
idstring-yesUnique identifier
onClosefunction-yesWhat happens on close. Usually sets the show state to false
closeOnClickboolean-noIf the menu should close on clicking
popperOptionsPopperOptions-noAll options allowed by PopperJS
anchorRefRefObject<HTMLElement>-yesThe element to anchor the menu to
DropdownMenuItemProps
interface DropdownMenuProps<Element extends React.ElementType> {
disabled?: boolean;
as?: Element;
}
NameTypeDefaultRequiredDescription
disabledboolean-noDisable element
asReact.ElementType'button'noSetting in DOM proper HTML Element and allowing only properties for it