1.0.0 • Published 3 years ago

shapla-react-sidenav v1.0.0

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

React Sidenav

A simple side overlay navigation for React.

Table of contents

Installation

npm install --save shapla-react-sidenav

Usage

Styles

with Sass:

import 'shapla-react-sidenav/src/index.scss';

with CSS:

import 'shapla-react-sidenav/dist/sidenav.css';

Javascript Instantiation

import React from 'react';
import Sidenav from 'shapla-react-sidenav';
 
class MyApp extends React.Component {

  constructor(props) {
    super(props);

    this.state = {
      activeLeftNav: false,
    }
  }

  render() {
    return (
      <div>
        <button onClick={() => this.setState({activeLeftNav: true})}>Show Sidenav</button>

        <Sidenav active={this.state.activeLeftNav} position={"left"}
                 onClose={() => this.setState({activeLeftNav: false})}/>
      </div>
    );
  }
}

Props

PropertyTypeRequiredDefaultDescription
activeBooleanyesfalseSet true to show sidenav
showOverlayBooleannotrueSet false to hide overlay
navWidthStringno300pxNavigation width
positionStringnoleftValue can be one of left, right, bottom, top
onCloseFunctionno()=>{}Will trigger this when user click on background.