Giter VIP home page Giter VIP logo

traversy-media-hamburger-menu's Introduction

Traversy Media's Hamburger Menu

A React Component based on Traversy Media's Hamburger menu & overlay

Credits

All credits related to the animations and styles in general go to Brad Traversy for his original tutorial, which you can find here -> https://www.youtube.com/watch?v=DZg6UfS5zYg&t=954s.

Original code:

https://codepen.io/bradtraversy/pen/vMGBjQ

Usage

  1. Install the package: npm i --save traversy-media-hamburger-menu or yarn add traversy-media-hamburger-menu
  2. import Menu and MenuItem to your component, like so:
import Menu, { MenuItem } from "traversy-media-hamburger-menu";
  1. Now you can use it like any other react component:
<Menu>
    <MenuItem
        text="I'm a neat component!"
        href="http://pudim.com.br"
        onClick={() => alert("You have clicked me!")}
    />
</Menu>

Styling

You can style the hamburger menu, overlay and menu items with ease like this:

<Menu
    hamburgerStyles={{
        backgroundColor: "#d32f2f"
    }}
    hamburgerLinesStyles={{ backgroundColor: "#333" }}
    overlayStyles={{ backgroundColor: "#333" }}
>
    <MenuItem text="Google" href="https://google.com" />
    <MenuItem text="Bing" href="https://bing.com" />
    <MenuItem text="Yahoo" href="https://yahoo.com" />
    <MenuItem
        text="Click me"
        href="#"
        onClick={() => alert("You're Awesome!")}
        menuItemStyles={{
            backgroundColor: "#d32f2f",
            color: "white"
        }}
    />
</Menu>

Tips about the MenuItem

If you want to render a simple link ("a" tag), you can use MenuItem like shown previously. But what if you want to render some other component like react-router-dom's <Link>? Well, you can do it like this:

<MenuItem>
    <Link to="/" />
<MenuItem/>

easy peasy, right? Just have in mind that the onClick WILL NOT be called in this case.

Final words

Hope you enjoy using this component the same as I have while creating It! Give this repo a star if you liked it, and feel free to open an issue if you find any problems.

traversy-media-hamburger-menu's People

Contributors

gustavo-kuze avatar

Watchers

 avatar  avatar

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.