navigator

A modern navigation drawer with react

Jan 21, 2021
A modern navigation drawer with react

react-modern-drawer

A modern navigation drawer with react.creating drawers made easy!

View Demo View Github

Install

npm install --save react-modern-drawer

or if you are using yarn :

yarn add react-modern-drawer

Usage

import React from 'react' // import component ???? import Drawer from 'react-modern-drawer' //import styles ???? import 'react-modern-drawer/dist/index.css' const App = () => { const [isOpen, setIsOpen] = React.useState(false) const toggleDrawer = () => { setIsOpen((prevState) => !prevState) } return ( <> <button onClick={toggleDrawer}>Show</button> <Drawer open={isOpen} onClose={toggleDrawer} direction='right'> <div>Hello World</div> </Drawer> </> ) } export default App

API

apityperequireddefaultvaluedesciption
directionstringyes"right""right" , "left" , "top","bottom"Selecting the direction that drawer opens
openbooleanyesfalsetrue , falseSelect when to show drawer
onClosefunctionyes( )=>{ }any executable functionThis function is called when clicking on backdrop layer usually used for closing the drawer
sizenumberno250Any positive IntegerDetermines the size of drawer in pixels
styleReact.CSSPropertiesnonullNormal stylingsCan be used for inline styles
durationnumberno300Any positive IntegerDetermines the duration of opening the drawer
overlayOpacitynumberno0.4Number between 0 and 1Determines the opacity of overlay
overlayColorstringno"#000"Any color codeDetermines the color of overlay
zIndexnumberno100Any positive IntegerDetermines the zIndex of drawer
childrenReact.ReactNodenonullAny ReactNodeThis is the same as props.children

Contribution

clone the project and run yarn install then run yarn start to run the main project.

then cd example and run yarn start to start the development example in order to test the component.

any PRs are welcome !!!

GitHub

Recommended