Coder Social home page Coder Social logo

react-hamburger-menu's Introduction

React Hamburger Menu

Built for React, this is a handy UI component for a menu icon in a mobile site or application.

Installation

react-hamburger-menu requires React 0.14 or later.

npm install --save react-hamburger-menu

Demo & Example

Live demo: cameronbourke.github.io/react-hamburger-menu

To build the example locally, clone this repo then run:

npm install
npm start
Then open localhost:8080 in a browser.

Usage

React Hamburger Menu only has two required props. They are isOpen and menuClicked. The other 7 props are optional.

menuClicked

Note: This prop is passed a function. This function will be invoked when the component is clicked. The function should responsible for updating the state that is passed to isOpen. The function passed to menuClicked could look something like the following:

handleClick() {
	this.setState({
		open: !this.state.open
	});
}

An example use of React Hamburger Menu looks like:

<HamburgerMenu
	isOpen={this.state.open}
	menuClicked={this.handleClick.bind(this)}
	width={18}
	height={15}
	strokeWidth={1}
	rotate={0}
	color='black'
	borderRadius={0}
	animationDuration={0.5}
/>

Note, not all props are required. All the props besides isOpen and menuClicked have defaults.

Options

Property Type Default Description
isOpen bool undefined determines whether the menu is a hamburger or cross icon
menuClicked func undefined will be invoked when the component is clicked
width number 36 the width of the icon
height number 30 the height of the icon
strokeWidth number 2 the stroke width of the lines
rotate number 0 the rotation of the icon, eg {45} would be 45deg
color string #000 the color of both icons
borderRadius number 0 the border radius of the lines
animationDuration number 0.4 the length of time it takes for the icon transitions to complete.

Todo

  • Add Unit Tests

License

MIT Licensed Copyright (c) Cameron Bourke 2016

react-hamburger-menu's People

Contributors

alanmoo avatar justinkchen 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.