Giter VIP home page Giter VIP logo

abusayid693 / react-hamburger-menus Goto Github PK

View Code? Open in Web Editor NEW
9.0 2.0 4.0 2.38 MB

๐Ÿ” A zero dependancy react library for creating animated hamburger menus with CSS transitions.

Home Page: https://www.npmjs.com/package/react-hamburger-menus

License: MIT License

JavaScript 3.78% HTML 0.82% TypeScript 67.69% SCSS 27.22% Shell 0.50%
hamburger hamburger-menu burger-menu react-navigation

react-hamburger-menus's Introduction

react-hamburger-menus

Congrats! You just saved yourself hours of work by using react-animated-navbars library for creating animated navigation panels

Demo

Take a look at the live demo!

Installation

install it using npm or yarn to include it in your own React project

You will also need to import css modules in root your project before using it. dist/react-animated-navbars.cjs.development.css

npm

npm i react-hamburger-menus

yarn

yarn add react-hamburger-menus

Usage

Ghost Navbar

  • Import GhostNavbar component from react-animated-navbars
  • Import styles react-animated-navbars/dist/style.css
import React from "react";
import { GhostNavbar } from "react-hamburger-menus";
import "react-hamburger-menus/dist/style.css";

const App = () => {
  return (
    <>
      <GhostNavbar
        styles={{
          floatButtonSize: 0.9,
          floatButtonX: 6,
          floatButtonY: 4
        }}
      >
        <ul>
          <li>ABOUT</li>
          <li>PROJECTS</li>
          <li>ELEMENTS</li>
          <li>CONTACT</li>
        </ul>
      </GhostNavbar>
    </>
  );
};

export default App;

Using with next js/ Gatsby js or other React Framework for application routing

import Link from 'next/link'
.
.
  <ul>
    <li>
      <Link href="/"> Home </Link>
    </li>  
    .
    .

๐Ÿ”จ API

Props

Direct props use ul tag with li or else animations wont be applied

Prop Type Default Description
children ReactNode (ul > li) optional Navbar items
className string optional Base class
styles styles object optional Base styles
iconHeight, iconWidth, iconColor string optional Icon style
floatButtonX number 85 Ghost button X position from right
floatButtonY number 2 Ghost button Y position from top
listHoverColor [string, string] [color 1, color 2] Hover animation color
fontColor, fontSize, fontHoverColor optional string common text styling
zIndex number optional z-Index (1000)
leftReveal, rightReveal, backgroundBox, backgroundCircle string leftReveal backgroundCircle annimation types

STYLES

If you want custom styles pass your CSS styling(Javascript Object) in Styles props using specific key mentioned below to apply styling correctly.

Take a look at the live demo for custom styling!

Property Type Default Description
navigation React CSS Properties optional Base styling
navigationButton React CSS Properties optional Ghost button styling
navigationIcon React CSS Properties optional Ghost icon styling
navigationBackground React CSS Properties optional Panel background styling

Responsive Navbar

Preview

Small screen

Large screen

import React from "react";
import { ResponsiveNavbar } from "react-hamburger-menus";
import "react-hamburger-menus/dist/style.css";

export const Default = () => (
  <ResponsiveNavbar
    logo={<p>Logo</p>}
    styles={{
      navigation: { fontFamily: 'Arial, Helvetica, sans-serif' },
      navigationBarSmall: {
        backgroundColor: 'aliceblue',
      },
      navigationCardSmall: {
        backgroundColor: 'aliceblue',
      },
    }}
  >
      <ul>
        <li>ABOUT</li>
        <li>PROJECTS</li>
        <li>ELEMENTS</li>
        <li>CONTACT</li>
      </ul>

  </ResponsiveNavbar>
);

๐Ÿ”จ API

Props

Direct props use ul tag with li or else animations wont be applied

Prop Type Default Description
children ReactNode (ul > li) optional Navbar items
className string optional Base class
styles styles object optional Base styles
logo ReactNode optional Navbar logo
iconColor, iconWidth, iconHeight string optional Icon styling (toggle)
zIndex number optional z-Index (1000)
animationDelay number string optional
toggleNavigationBarSmallValue boolean optional manual toggle value
toggleNavigationBarSmallFunction VoidFunction optional manual toggle function

STYLES

If you want custom styles pass your CSS styling(Javascript Object) in Styles props using specific key mentioned below to apply styling correctly.

Take a look at the live demo for custom styling!

Property Type Default Description
navigation React CSS Properties optional Base styling
navigationBarSmall React CSS Properties optional Navbar small screen styling
navigationButtonSmall React CSS Properties optional Navbar button small screen styling (toggle)
navigationCardSmall React CSS Properties optional Navbar card small screen styling (toggle)
navigationBarLarge React CSS Properties optional Navbar card large screen styling (toggle)

Ghost Button

import React from "react";
import { GhostButton } from "react-hamburger-menus";
import "react-hamburger-menus/dist/style.css";

const App = () => {
  return (
    <>
      <GhostButton
        styles={{
          floatButtonX: 85,
          floatButtonY: 7
        }}
      >
          <ul>
          <li>ABOUT</li>
          <li>PROJECTS</li>
          <li>ELEMENTS</li>
          <li>CONTACT</li>
        </ul>
        </GhostButton>
    </>
  );
};

export default App;

Using icon or html (as icon)

.
  <GhostButton
    icon={
      <p style={{ fontSize: '19px', borderBottom: '1px solid grey' }}>Users</p>
    }
    />
.
.

๐Ÿ”จ API

Props

Prop Type Default Description
children ReactNode (ul > li) optional Navbar items
className string optional Base class
styles styles object optional Base styles
icon ReactNode optional custom icon
floatButtonSize number optional Ghost button size (just number)
floatButtonX number 85 Ghost button X position from right
floatButtonY number 2 Ghost button Y position from top
fontColor, fontSize optional string common text styling
iconHeight, iconWidth, iconColor string optional Icon style
listHoverColor string aqua Hover animation color
zIndex number optional z-Index (1000)

STYLES

Take a look at the live demo for custom styling!

Property Type Default Description
navigation React CSS Properties optional Base styling
navigationButton React CSS Properties optional Ghost button styling
navigationIcon React CSS Properties optional Ghost icon styling
navigationCard React CSS Properties optional Panel pop-up card styling

๐Ÿ› Bug Reporting

The Library is in developing stage

  • Feel free to Open an issue on GitHub to request any additional features you might need for your use case.
  • Connect with me on LinkedIn. I'd love โค๏ธ๏ธ to hear where you are using this library.

Browser support

Because this project uses CSS3 features, it's only meant for modern browsers. Some browsers currently fail to apply some of the animations correctly.

It is well tested for chrome, safari and firefox.

๐Ÿ“œ License

This software is open source, licensed under the MIT License.

react-hamburger-menus's People

Contributors

abusayid693 avatar dependabot[bot] avatar ernestdadev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

react-hamburger-menus's Issues

USING LINK IN NEXTJS

Nice package. There seems to be an issue with the menu closing on mobile devices. I have the responsive menu in a global layout using NextJS so when it switches to mobile and you tap a menu item, it does not close up the menu.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.