React Off-Canvas
Off-canvas menus for React.
Installation
$ npm install --save react-offcanvas
Usage
Basic Usage
<OffCanvas = = = = => <OffCanvasBody = => This is the canvas body </OffCanvasBody> <OffCanvasMenu = => This is the canvas menu </OffCanvasMenu></OffCanvas>
Within An Application
You'll need to hook up your application to handle the state for toggling the menu. Check out the basic example below:
"use strict"; ;; { // sets the initial state this; } { return <OffCanvas width=300 transitionDuration=300 effect="parallax" isMenuOpened=thisstateisMenuOpened position="right" > <OffCanvasBody className=stylesbodyClass style= fontSize: "30px" > <p>This is the main body container</p> <p> <a href="#" onClick=thishandleClick> Click here </a>" " to toggle the menu </p> </OffCanvasBody> <OffCanvasMenu className=stylesmenuClass> <p>Placeholder content</p> <ul> <li>Link 1</li> <li>Link 2</li> <li>Link 3</li> <li>Link 4</li> <li>Link 5</li> <li> <a href="#" onClick=thishandleClick> Toggle Menu </a> </li> </ul> </OffCanvasMenu> </OffCanvas> ; } { // toggles the menu opened state this; }
Components
OffCanvas
This is the main component you will be using to compose your body and menu.
Prop | Type | Default | Description |
---|---|---|---|
width |
number |
250 | The width of the menu and off-canvas transition. |
transitionDuration |
number |
250 | The time in ms for the transition. |
isMenuOpened |
bool |
false | Is the menu opened or not. |
position |
string |
"left" | Position the menu to the "left" or "right". |
effect |
string |
"push" | Choose menu effect. "push", "overlay" or "parallax". |
OffCanvasBody
Prop | Type | Default | Description |
---|---|---|---|
width |
number |
250 | The width of the menu and off-canvas transition. |
transitionDuration |
number |
250 | The time in ms for the transition. |
isMenuOpened |
bool |
false | Is the menu opened or not. |
position |
string |
"left" | Position the menu to the "left" or "right". |
className |
string |
Custom className for the element. | |
style |
object |
CSS style object for the element. |
OffCanvasMenu
Prop | Type | Default | Description |
---|---|---|---|
width |
number |
250 | The width of the menu and off-canvas transition. |
transitionDuration |
number |
250 | The time in ms for the transition. |
isMenuOpened |
bool |
false | Is the menu opened or not. |
position |
string |
"left" | Position the menu to the "left" or "right". |
className |
string |
Custom className for the element. | |
style |
object |
CSS style object for the element. |