React component for adding a hidden sidebars to your project. Simply this is a Bootstrap 5 Offcanvas component but without installing any dependencies.
![GitHub](https://camo.githubusercontent.com/a452375866150e6839e615ae06eda9933e2587c975bf01b53f6dd4db11859ae8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f617772616e352f72656163742d73696d706c652d6f666663616e766173)
npm i react-simple-offcanvas
yarn add react-simple-offcanvas
import React from 'react'
import { OffcanvasProvider, Trigger, Offcanvas } from 'react-simple-offcanvas'
export default function App() {
return (
<OffcanvasProvider { /* Provider props */ }>
<Trigger { /* Trigger props */ } />
<Offcanvas { /* Offcanvas props */ } />
</OffcanvasProvider>
)
}
Prop |
Type |
Options |
Description |
Default |
onOpen |
Function |
Optional |
Callback function that is triggered when the Offcanvas is opened |
- |
onClose |
Function |
Optional |
Callback function that is triggered when the Offcanvas is closed |
- |
Prop |
Type |
Options |
Description |
Default |
component |
String |
Optional |
Render Component button | div |
button |
className |
String |
Optional |
CSS className applied to the Trigger Block |
offcanvas-trigger |
styles |
CSSProperties |
Optional |
Inline style |
{} |
children |
ReactNode |
Optional |
Component children |
- |
Prop |
Type |
Options |
Description |
Default |
title |
String |
Optional |
Offcanvas Title (h5 Tag) |
Offcanvas Title |
position |
String |
Optional |
left | right | top | bottom |
right |
backdrop |
boolean |
Optional |
Apply a backdrop on body while offcanvas is open |
true |
allowClickAway |
boolean |
Optional |
Closes the offcanvas when user click outside |
true |
allowEsc |
boolean |
Optional |
Closes the offcanvas when escape key is pressed |
true |
allowScroll |
boolean |
Optional |
Allow body scrolling while offcanvas is open |
true |
className |
String |
Optional |
CSS className applied to the Offcanvas Block |
simple-offcanvas |
styles |
CSSProperties |
Optional |
Inline style |
{} |
children |
ReactNode |
Optional |
Component Children |
Some text as placeholder |
![Edit react-simple-offcanvas](https://camo.githubusercontent.com/97cbe82b1619b42e1f78fce9db09104b932a9da1fd37751f4d9c41f4fe350241/68747470733a2f2f636f646573616e64626f782e696f2f7374617469632f696d672f706c61792d636f646573616e64626f782e737667)
MIT © awran5