Gathering detailed insights and metrics for react-pro-sidebar
Gathering detailed insights and metrics for react-pro-sidebar
Gathering detailed insights and metrics for react-pro-sidebar
Gathering detailed insights and metrics for react-pro-sidebar
npm install react-pro-sidebar
82.6
Supply Chain
90.1
Quality
77
Maintenance
100
Vulnerability
99.6
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
1,733 Stars
313 Commits
414 Forks
15 Watching
8 Branches
7 Contributors
Updated on 28 Nov 2024
Minified
Minified + Gzipped
TypeScript (97.31%)
HTML (1.49%)
JavaScript (1.15%)
Shell (0.05%)
Cumulative downloads
Total Downloads
Last day
-12.1%
9,651
Compared to previous day
Last week
-4.1%
55,275
Compared to previous week
Last month
10.4%
232,137
Compared to previous month
Last year
41.9%
2,505,905
Compared to previous year
40
React Pro Sidebar provides a set of components for creating high level and customizable side navigation
1yarn add react-pro-sidebar
1npm install react-pro-sidebar
1import { Sidebar, Menu, MenuItem, SubMenu } from 'react-pro-sidebar'; 2 3<Sidebar> 4 <Menu> 5 <SubMenu label="Charts"> 6 <MenuItem> Pie charts </MenuItem> 7 <MenuItem> Line charts </MenuItem> 8 </SubMenu> 9 <MenuItem> Documentation </MenuItem> 10 <MenuItem> Calendar </MenuItem> 11 </Menu> 12</Sidebar>;
You can make use of the component
prop to integrate React Router link
Example Usage
1import { Sidebar, Menu, MenuItem } from 'react-pro-sidebar'; 2import { Link } from 'react-router-dom'; 3 4<Sidebar> 5 <Menu 6 menuItemStyles={{ 7 button: { 8 // the active class will be added automatically by react router 9 // so we can use it to style the active menu item 10 [`&.active`]: { 11 backgroundColor: '#13395e', 12 color: '#b6c8d9', 13 }, 14 }, 15 }} 16 > 17 <MenuItem component={<Link to="/documentation" />}> Documentation</MenuItem> 18 <MenuItem component={<Link to="/calendar" />}> Calendar</MenuItem> 19 <MenuItem component={<Link to="/e-commerce" />}> E-commerce</MenuItem> 20 </Menu> 21</Sidebar>;
We provide for each component rootStyles
prop that can be used to customize the styles
its recommended using utility classes (sidebarClasses
, menuClasses
) for selecting target child nodes
Example usage
1<Sidebar 2 rootStyles={{ 3 [`.${sidebarClasses.container}`]: { 4 backgroundColor: 'red', 5 }, 6 }} 7> 8 // ... 9</Sidebar>
For Menu
component, in addition to rootStyles
you can also use menuItemStyles
prop for customizing all MenuItem
& SubMenu
components and their children
Type definition
1interface MenuItemStyles { 2 root?: ElementStyles; 3 button?: ElementStyles; 4 label?: ElementStyles; 5 prefix?: ElementStyles; 6 suffix?: ElementStyles; 7 icon?: ElementStyles; 8 subMenuContent?: ElementStyles; 9 SubMenuExpandIcon?: ElementStyles; 10} 11 12type ElementStyles = CSSObject | ((params: MenuItemStylesParams) => CSSObject | undefined);
Example usage
1<Sidebar> 2 <Menu 3 menuItemStyles={{ 4 button: ({ level, active, disabled }) => { 5 // only apply styles on first level elements of the tree 6 if (level === 0) 7 return { 8 color: disabled ? '#f5d9ff' : '#d359ff', 9 backgroundColor: active ? '#eecef9' : undefined, 10 }; 11 }, 12 }} 13 > 14 //... 15 </Menu> 16</Sidebar>
Component | Prop | Type | Description | Default |
---|---|---|---|---|
Sidebar | defaultCollapsed | boolean | Initial collapsed status | false |
collapsed | boolean | Sidebar collapsed state | false | |
toggled | boolean | Sidebar toggled state | false | |
width | number | string | Width of the sidebar | 270px | |
collapsedWidth | number | string | Width of the sidebar on collapsed state | 80px | |
backgroundColor | string | Set background color for sidebar | rgb(249, 249, 249, 0.7) | |
image | string | Url of the image to use in the sidebar background, need to apply transparency to background color | - | |
breakPoint | xs | sm | md | lg | xl | xxl | all | Set when the sidebar should trigger responsiveness behavior | - | |
customBreakPoint | string | Set custom breakpoint value, this will override breakPoint prop | - | |
transitionDuration | number | Duration for the transition in milliseconds to be used in collapse and toggle behavior | 300 | |
rtl | boolean | RTL direction | false | |
rootStyles | CSSObject | Apply styles to sidebar element | - | |
onBackdropClick | () => void | Callback function to be called when backdrop is clicked | - | |
Menu | closeOnClick | boolean | If true and sidebar is in collapsed state, submenu popper will automatically close on MenuItem click | false |
menuItemStyles | MenuItemStyles | Apply styles to MenuItem and SubMenu components and their children | - | |
renderExpandIcon | (params: { level: number; collapsed: boolean; disabled: boolean; active: boolean; open: boolean; }) => React.ReactNode | Render method for customizing submenu expand icon | - | |
transitionDuration | number | Transition duration in milliseconds to use when sliding submenu content | 300 | |
rootStyles | CSSObject | Apply styles from Menu root element | - | |
MenuItem | icon | ReactNode | Icon for the menu item | - |
active | boolean | If true , the component is active | false | |
disabled | boolean | If true , the component is disabled | - | |
prefix | ReactNode | Add a prefix to the menuItem | - | |
suffix | ReactNode | Add a suffix to the menuItem | - | |
component | string | ReactElement | A component used for menu button node, can be string (ex: 'div') or a component | - | |
rootStyles | CSSObject | Apply styles to MenuItem element | - | |
SubMenu | label | string | ReactNode | Label for the submenu | - |
icon | ReactNode | Icon for submenu | - | |
defaultOpen | boolean | Set if the submenu is open by default | false | |
open | boolean | Set open value if you want to control the state | - | |
active | boolean | If true , the component is active | false | |
disabled | boolean | If true , the component is disabled | - | |
prefix | ReactNode | Add a prefix to the submenu | - | |
suffix | ReactNode | Add a suffix to the submenu | - | |
onOpenChange | (open: boolean) => void | Callback function called when submenu state changes | - | |
component | string | React.ReactElement | A component used for menu button node, can be string (ex: 'div') or a component | - | |
rootStyles | CSSObject | Apply styles to SubMenu element | - |
MIT © Mohamed Azouaoui
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
Found 1/6 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
49 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More