I am trying to create a Bootstrap sidebar like this picture here.
I have looked at all the code on react-bootstrap and Twitter Bootstrap and I am yet to find a how-to code this. Basically, if they are viewing on a desktop, I want the sidebar to be visible, otherwise hidden.
The sidebar should stay still while the content on the page scrolls up and down.
4
Answers
Ok so for people who want to make a sidebar sadly the news is you gotta make it all yourself.
What I have done is the following.
Then final step In the file you want it to be show in do the following
One can now use a library,
react-bootstrap-drawer
, which provides a sidenav / drawer which was taken directly from thereact-bootstrap
documentation. Oddly, this is not a component provided by the library itself so one must use a third-party library:See: https://github.com/SimpleSigner/react-bootstrap-drawer
of course, you have to make the navbar yourself and the examples above are very valid, but cdbreact speeds up the process a lot faster. just add cdbreact using
npm I cdbreact
or
yarn add cdbreact
and then import CDBSidebar, CDBSidebarContent, CDBSidebarHeader, etc. with cdbreact, you don’t need to bother about installing bootsrap in your react app.
cdbreact also comes with icons, and a lot more.
import React from ‘react’
import {CDBSidebar,
CDBSidebarContent,
CDBSidebarHeader,
CDBSidebarFooter, CDBSidebarMenu,
CDBSidebarMenuItem} from ‘cdbreact’;
import {NavLink, Link} from ‘react-router-dom’;
import {} from ‘react-router-dom’;
you can also follow the guide here https://dev.to/devwares/how-to-create-a-responsive-sidebar-in-react-using-bootstrap-and-contrast-5gi2 follow this link to see
As of 2022 there is pure react-boostrap based component called
react-boostrap-sidebar-menu
. It is the cleanest solution so far and quite customizable.https://www.npmjs.com/package/react-bootstrap-sidebar-menu
https://github.com/ivp-dev/react-bootstrap-sidebar-menu