2.0.0 • Published 2 years ago

burger-menu v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

NPM LICENSE CODECOV

🎉 Features

  • Written in Typescript, Friendly Static Type Support.

🔥 Demo

Live demo: burger-menu

🔥 Install

# with npm
npm install burger-menu

# with yarn
yarn add burger-menu

👍 Usage

Here is a quick example to get you started, it's all you need:

import React, { useState } from "react";
import { createRoot } from 'react-dom/client';
import { Menu, SubMenu, Item } from "burger-menu";
import 'burger-menu/lib/index.css';

const App = () => {
  const [isOpen, setIsOpen] = useState(false);
  return (
    <>
      <div onClick={() => setIsOpen(!isOpen)}>Icon</div>
      <Menu className="burger-menu" isOpen={isOpen} selectedKey={'entry'} onClose={() => setIsOpen(false)}>
        <Item itemKey={'manage'} text={'User Management'}></Item>
        <Item itemKey={'user'} text={'User Center'}></Item>
        <SubMenu title="Union Management">
          <Item itemKey={'notice'} text={'Announcement'}></Item>
          <Item itemKey={'union'} text={'Union Inquiries'}></Item>
          <Item itemKey={'entry'} text={'Entry information'}></Item>
        </SubMenu>
      </Menu>
    </>
});

createRoot(document.getElementById('root')).render(<App />);

How to import

import { Menu, SubMenu } from 'burger-menu';
import 'burger-menu/lib/index.css';

Animations

The usage above imported slide which renders a menu that slides in when the burger icon is clicked. To use a different animation you can substitute slide with any of the following (check out the demo to see the animations in action):

  • slide
  • fallDown

API Reference

PropertiesDescriptionTypeDefault
isOpenControl open statebooleanfalse
widthWidthnumber | string300
sideSliding positionstringright
animateanimate typestringslide
durationtransition durationstring300ms
customCrossIconIcon for close buttonReactNodefalse
customIconCustom icon or logo component, will be displayed on the head leftReactNodefalse
onOpenThe Callback function when animation endfunction(e) => {}() => {}
onCloseThe callback function before the exit animation endsfunction(e) => {}() => {}
bodyClassNameAdd className to body tagstring
htmlClassNameAdd className to html tagstring
noOverlayToggle whether to show overlaybooleanfalse
overlayClassNameOverlay style namestring

SubMenu

PropertiesDescriptionTypeDefault
titleSubMenu copystring
iconIcon of SubMenu, will be displayed on the rightReactNode

Item

PropertiesDescriptionTypeDefault
textContent for itemstring
iconThe icon of the menu item, will be displayed on the leftReactNode
itemKeyUnique ID of the menu itemstring

🎈 License

Burger Menu is MIT Licensed

2.0.0

2 years ago

1.0.13

3 years ago

1.0.9

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.12

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago