react-sliding-sidemenu
react sliding sidemenu is a fully customizable with zero dependancy, written in pure JS and CSS responsive sidebar menu. this will gives a quick access to menu links to navigate through different routes in application.
Installation
npm install react-sliding-sidemenu --save
customisable features
- color of the text inside the sidebar menu
- margin-top of the sidebar
- font style
- order of content inside sidebar (profile,description and links sections)
- upto 2 levels of sub links
- customisable expand icon style
- links will support react-router
- profile and description sections can be hidden if not required.
- full view of the profile pic on click.
Using react-sliding-sidemenu
import componnent from :- react-sliding-sidemenu_ in your component. pass props to the component with data and avaialbe props to customise and you are done.
Component { return <div> //call the Sidebar component with props <Sidebar ...props> </div> ; } ReactDOM
Available features from props
Props | Description | Examples |
---|---|---|
top | sets the margin-top | number : 80,100,150 etc |
expandIconStyle | different icons available from bootstrap 3.3.7 | plus, chevron-right , arrow-right, circle-arrow-right,menu-right,menu-hamburger |
profileVisible | if true , profile section will be visible | trus,false |
Color of the text inside side menu | string : 'black' ,'#000' | |
fontStyle | Font style/font family of the text inside side menu | 'Arial', 'Helvetica', 'sans-serif' |
fontSize | sets the font size of the text inside side menu | number: 25(default),30 50 |
ProfileName | Sets the profile name | string: 'any string' |
hasReactRouterLinks | pass this as true if application is using react-router to navigate | true,false |
descriptionVisible | if true , description section will be visible | true,false |
sidebarTitle | Title of the sidebar | string: 'any string'(30 characters are preferred) |
descriptionContent | free text or html element to be passed. this will be the content of the description section. | string: 'any free text ' or ' any free text ' |
orderOfContents | specifies in which order the profile,description and links section should be visible | object : orderOfContents{profile: 1, description: 2, links: 3 } |
profileImage | Provide the image for profile picture | import image variable |
dataForLinks | array of objects to be passed for generating links | Array of objects (explained below) |
functions
onLinkItemClick(clickedLink)
this function can be passed as props to the component , which will be executed on click of the menu links. function will recieve an arguement which holds the details of the clicked link. Note to use above function pass href for that link as "#".At a time either href or onClick one of can be used.
dataForLinks sample object
href below indicates the navigation to be routed on click on the links.(same as href for anchor tag) **Note : ** all properties are case sensitive.
dataForLinks: mainLink: "Main Link 1" href: "pass the link" subLinks: subLink: "Sub Link 1" href: "pass the link" childLinks: childLink: 'Child Link 1' href: 'pass the link' childLink: 'Child Link 2' href: 'pass the link' subLink: "Sub Link 2" href: "pass the link" childLinks: subLink: "SubLink 3" href: "pass the link" childLinks: mainLink: "Main Link 3" href: "pass the link" subLinks: