Skip to main content

Content Menu

v.6.0.0

Installation

yarn add @mercell/content-menu-react

Usage

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

import ContentMenu from '@mercell/content-menu-react';
Live Editor
Result

Types, definitions, etc.

ContentMenuProps
type ContentMenuProps = {
selectedItem: string;
selectedItemType?: 'path' | 'title';
primaryItems: ContentMenuItem[];
secondaryItems?: ContentMenuItem[];
onClick: (
e: MouseEvent<HTMLAnchorElement>,
title: string,
path: string
) => void;
} & Omit<JSX.IntrinsicElements['div'], 'onClick'>
NameTypeDefaultRequiredDescription
selectedItemstring-yesthe title of the selected item (highlighted in the menu)
selectedItemType'path' | 'title''title'notype based on which we know which item is selected
primaryItemsContentMenuItem[]-yesan array of ContentMenuItem
secondaryItemsContentMenuItem[]-noan additional array of ContentMenuItem (optional)
onClick( e:MouseEvent<HTMLAnchorElement>, title: string, path: string) => void-yesuse if you want to do any additional action other than navigate
ContentMenuItem
type ContentMenuItem = {
title: string;
path: string;
ariaLabel?: string;
disabled?: boolean;
};
NameTypeDefaultRequiredDescription
titlestring-yesspecifies the link's title
pathstring-yesspecifies the link's URL
ariaLabelstring-noAria-Label for menu item
disabledboolean-noDisable menu item