1.0.2 • Published 11 months ago

react-megamenu-responsive v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

React Mega Menu

NPM Downloads npm package minimized gzipped size NPM Version

It's a mega menu component on React. It comes with features like fullwidth, call to action button, image, and responsible for mobile/tablet device.

megamenu2

megamenu1

Features:

  • fullwidth mode
  • CTA button
  • image
  • responsible for mobile/tablet

Table of contents

Install

npm i react-megamenu

Attention

ReactMegaMenu component must use between BrowserRouter tag

Usage

simple mega menu

import { BrowserRouter } from 'react-router-dom';
import ReactMegaMenu from 'react-megamenu-responsive';
import type { MenuType } from 'react-megamenu-responsive';

const menu: MenuType[] = [
  {
    id: "1",
    title: "Phone",
    href: "#",
    items: [
      { id: "1", title: "Phone 9", href: "#" },
      { id: "2", title: "Phone 10", href: "#" },
      { id: "3", title: "Phone 11", href: "#" },
    ],
    description: "my phones are very useful",
  },
  {
    id: "2",
    title: "Monitor",
    href: "#",
    items: [
      { id: "1", title: "Monitor m1", href: "#" },
      { id: "2", title: "Monitor m2", href: "#" },
    ]
  },
  {
    id: "3",
    title: "Laptop",
    href: "#",
    items: [
      { id: "1", title: "Laptop l1", href: "#" },
      { id: "2", title: "Laptop l2", href: "#" },
      { id: "3", title: "Laptop l3", href: "#" },
    ]
  },
]

export default function Example() {
  return (
    <BrowserRouter >
      <ReactMegaMenu menus={menu} />
    </BrowserRouter>
  )
}

API

ReactMegaMenu

The component accepts the following props:

NameTypeDescription
directionlrt | rtl | inheritDirection used to describe direction of menu.
menusarrayUsed to describe menus. Must be either an array of objects describing a menu. (This field is required)
optionsobjectOptions used to describe mega menu.

Menu Options

NameTypeDefaultDescription
colorobjectUser provided colors to customized menu.
fullWidthbooleanfalsePossible values:true: Mega menu is fullwidth.false: Mega menu is not fullwidth. Example
imageobjectUser provided image to customized menu. Example
CTAobjectUser provided CTA button to customized menu. Example

CSS Classes

These class names are useful for styling with CSS. They are applied to the component.

NameDescription
rmm-megamenu-mainStyles applied to the mega menu
rmm-megamenu-menuStyles applied to the menu
rmm-megamenu-ctaStyles applied to the CTA section
rmm-megamenu-cta__titleStyles applied to the CTA title
rmm-megamenu-cta__desStyles applied to the CTA description
rmm-megamenu-imgStyles applied to the image section
rmm-megamenu-img__titleStyles applied to the image title
rmm-menu-mainStyles applied to the each of the menus
rmm-menu-headStyles applied to options of the header of menu
rmm-menu-head__iconStyles applied to the header icon
rmm-menu-head__linkStyles applied to the header link
rmm-menu-head__titleStyles applied to the header title
rmm-menu-head__desStyles applied to the header description
rmm-menu-ulStyles applied to the items
rmm-menu-itemStyles applied to the each of the items
rmm-menu-item__iconStyles applied to the item icon
rmm-menu-item__linkStyles applied to the item link
rmm-menu-item__titleStyles applied to the item title

Item Icon

On each item and menu object, you have the ability to choose icon to your liking with the 'icon' property. Example:

const menu: MenuType[] = [
  {
    id: "1",
    title: "Phone",
    href: "#",
    icon: <svg>...</svg>,
    items: [
      {
        id: "1", title: "Phone 9", href: "#", icon: <svg>...</svg>,
      },
      {
        id: "2", title: "Phone 10", href: "#", icon: <svg>...</svg>,
      },
      {
        id: "3", title: "Phone 11", href: "#", icon: <svg>...</svg>,
      },
    ],
    description: "my phones are very useful",
  }
]

Options

Change default options

const defaultOptions: OptionType = {
  color: {
    backgroundColor: "#fff",
    borderColor: "#ddd",
    headTitle: "#2563eb",
    description: "#2563eb",
    itemTitle: "#6b7280",
  },
  fullWidth: false,
}

License

The files included in this repository are licensed under the MIT license.

1.0.2

11 months ago

1.0.1

12 months ago

1.0.0

12 months ago