azouaoui-med/react-pro-sidebar

React Pro Sidebar provides a set of components for creating high level and customizable side navigation

TypeScript

1,793

353 commits

updated Oct 17, 2026

See the code

README

React Pro Sidebar

npm License Peer Download Stars

The ultimate sidebar component for React applications. Highly customizable, fully responsive, and effortless to integrate into any dashboard.

Documentation

Full documentation, guides and live examples are available at react-pro-sidebar.netlify.app.

Old versions

Live Preview

Screenshot

react-pro-sidebar

Installation

yarn

yarn add react-pro-sidebar

npm

npm install react-pro-sidebar

Requirements: React >= 18 (React 19 supported). react and react-dom are peer dependencies.

Migrating from v1

v2 removes the legacy hook API (useProSidebar, ProSidebarProvider), the defaultCollapsed prop and the breakPoint="always" value, and requires React 18+. See the migration guide for upgrade steps.

Usage

import { Sidebar, Menu, MenuItem, SubMenu } from 'react-pro-sidebar';

<Sidebar>
  <Menu>
    <SubMenu label="Charts">
      <MenuItem> Pie charts </MenuItem>
      <MenuItem> Line charts </MenuItem>
    </SubMenu>
    <MenuItem> Documentation </MenuItem>
    <MenuItem> Calendar </MenuItem>
  </Menu>
</Sidebar>;

Using React Router

You can make use of the component prop to integrate React Router link

Example Usage

import { Sidebar, Menu, MenuItem } from 'react-pro-sidebar';
import { NavLink } from 'react-router-dom';

<Sidebar>
  <Menu
    menuItemStyles={{
      button: {
        // NavLink adds the active class automatically,
        // so we can use it to style the active menu item
        [`&.active`]: {
          backgroundColor: '#13395e',
          color: '#b6c8d9',
        },
      },
    }}
  >
    <MenuItem component={<NavLink to="/documentation" />}> Documentation</MenuItem>
    <MenuItem component={<NavLink to="/calendar" />}> Calendar</MenuItem>
    <MenuItem component={<NavLink to="/e-commerce" />}> E-commerce</MenuItem>
  </Menu>
</Sidebar>;

Customization

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

<Sidebar
  rootStyles={{
    [`.${sidebarClasses.container}`]: {
      backgroundColor: 'red',
    },
  }}
>
  // ...
</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

interface MenuItemStyles {
  root?: ElementStyles;
  button?: ElementStyles;
  label?: ElementStyles;
  prefix?: ElementStyles;
  suffix?: ElementStyles;
  icon?: ElementStyles;
  subMenuContent?: ElementStyles;
  SubMenuExpandIcon?: ElementStyles;
}

type ElementStyles = CSSObject | ((params: MenuItemStylesParams) => CSSObject | undefined);

Example usage

<Sidebar>
  <Menu
    menuItemStyles={{
      button: ({ level, active, disabled }) => {
        // only apply styles on first level elements of the tree
        if (level === 0)
          return {
            color: disabled ? '#f5d9ff' : '#d359ff',
            backgroundColor: active ? '#eecef9' : undefined,
          };
      },
    }}
  >
    //...
  </Menu>
</Sidebar>

API

ComponentPropTypeDescriptionDefault
SidebarcollapsedbooleanSidebar collapsed statefalse
toggledbooleanSidebar toggled statefalse
widthnumber | stringWidth of the sidebar250px
collapsedWidthnumber | stringWidth of the sidebar on collapsed state80px
backgroundColorstringSet background color for sidebarrgb(249, 249, 249, 0.7)
imagestringUrl of the image to use in the sidebar background, need to apply transparency to background color -
breakPointxs | sm | md | lg | xl | xxl | all | stringSet when the sidebar should trigger responsiveness behavior. Accepts a predefined breakpoint or a custom CSS value (ex: 450px)-
transitionDurationnumberDuration for the transition in milliseconds to be used in collapse and toggle behavior300
rtlbooleanRTL directionfalse
rootStylesCSSObjectApply styles to sidebar element-
onBackdropClick() => voidCallback function to be called when backdrop is clicked-
onBreakPoint(broken: boolean) => voidCallback function to be called when the broken state changes-
MenucloseOnClickbooleanIf true and sidebar is in collapsed state, submenu popper will automatically close on MenuItem clickfalse
popoverbooleanIf true, top-level SubMenus open as floating poppers even when the sidebar is expanded (instead of sliding open inline)false
accordionbooleanIf true, only one top-level SubMenu can be open at a time; opening another closes the previously open onefalse
menuItemStylesMenuItemStylesApply styles to MenuItem and SubMenu components and their children -
renderExpandIcon(params: { level: number; disabled: boolean; active: boolean; open: boolean; }) => React.ReactNodeRender method for customizing submenu expand icon-
transitionDurationnumberTransition duration in milliseconds to use when sliding submenu content300
rootStylesCSSObjectApply styles from Menu root element-
MenuItemiconReactNodeIcon for the menu item -
activebooleanIf true, the component is activefalse
disabledbooleanIf true, the component is disabled -
prefixReactNodeAdd a prefix to the menuItem -
suffixReactNodeAdd a suffix to the menuItem -
componentstring | ReactElementA component used for menu button node, can be string (ex: 'div') or a component -
rootStylesCSSObjectApply styles to MenuItem element-
SubMenulabelstring | ReactNodeLabel for the submenu -
iconReactNodeIcon for submenu-
defaultOpenbooleanSet if the submenu is open by defaultfalse
openbooleanSet open value if you want to control the state-
activebooleanIf true, the component is active. Also set automatically when any descendant is activefalse
disabledbooleanIf true, the component is disabled -
prefixReactNodeAdd a prefix to the submenu -
suffixReactNodeAdd a suffix to the submenu -
accordionbooleanIf true, only one of this submenu's direct child SubMenus can be open at a timefalse
onOpenChange(open: boolean) => voidCallback function called when submenu state changes-
componentstring | React.ReactElementA component used for menu button node, can be string (ex: 'div') or a component -
rootStylesCSSObjectApply styles to SubMenu element-

License

MIT © Mohamed Azouaoui

dropdown-menus
menu
menus
npm
npm-package
react
react-component
reactjs
sidebar
submenu
submenus
tree-structure

azouaoui-med/react-pro-sidebar

React Pro Sidebar provides a set of components for creating high level and customizable side navigation

TypeScript

1,793

353 commits

updated Oct 17, 2026

See the code

README

React Pro Sidebar

npm License Peer Download Stars

The ultimate sidebar component for React applications. Highly customizable, fully responsive, and effortless to integrate into any dashboard.

Documentation

Full documentation, guides and live examples are available at react-pro-sidebar.netlify.app.

Old versions

Live Preview

Screenshot

react-pro-sidebar

Installation

yarn

yarn add react-pro-sidebar

npm

npm install react-pro-sidebar

Requirements: React >= 18 (React 19 supported). react and react-dom are peer dependencies.

Migrating from v1

v2 removes the legacy hook API (useProSidebar, ProSidebarProvider), the defaultCollapsed prop and the breakPoint="always" value, and requires React 18+. See the migration guide for upgrade steps.

Usage

import { Sidebar, Menu, MenuItem, SubMenu } from 'react-pro-sidebar';

<Sidebar>
  <Menu>
    <SubMenu label="Charts">
      <MenuItem> Pie charts </MenuItem>
      <MenuItem> Line charts </MenuItem>
    </SubMenu>
    <MenuItem> Documentation </MenuItem>
    <MenuItem> Calendar </MenuItem>
  </Menu>
</Sidebar>;

Using React Router

You can make use of the component prop to integrate React Router link

Example Usage

import { Sidebar, Menu, MenuItem } from 'react-pro-sidebar';
import { NavLink } from 'react-router-dom';

<Sidebar>
  <Menu
    menuItemStyles={{
      button: {
        // NavLink adds the active class automatically,
        // so we can use it to style the active menu item
        [`&.active`]: {
          backgroundColor: '#13395e',
          color: '#b6c8d9',
        },
      },
    }}
  >
    <MenuItem component={<NavLink to="/documentation" />}> Documentation</MenuItem>
    <MenuItem component={<NavLink to="/calendar" />}> Calendar</MenuItem>
    <MenuItem component={<NavLink to="/e-commerce" />}> E-commerce</MenuItem>
  </Menu>
</Sidebar>;

Customization

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

<Sidebar
  rootStyles={{
    [`.${sidebarClasses.container}`]: {
      backgroundColor: 'red',
    },
  }}
>
  // ...
</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

interface MenuItemStyles {
  root?: ElementStyles;
  button?: ElementStyles;
  label?: ElementStyles;
  prefix?: ElementStyles;
  suffix?: ElementStyles;
  icon?: ElementStyles;
  subMenuContent?: ElementStyles;
  SubMenuExpandIcon?: ElementStyles;
}

type ElementStyles = CSSObject | ((params: MenuItemStylesParams) => CSSObject | undefined);

Example usage

<Sidebar>
  <Menu
    menuItemStyles={{
      button: ({ level, active, disabled }) => {
        // only apply styles on first level elements of the tree
        if (level === 0)
          return {
            color: disabled ? '#f5d9ff' : '#d359ff',
            backgroundColor: active ? '#eecef9' : undefined,
          };
      },
    }}
  >
    //...
  </Menu>
</Sidebar>

API

ComponentPropTypeDescriptionDefault
SidebarcollapsedbooleanSidebar collapsed statefalse
toggledbooleanSidebar toggled statefalse
widthnumber | stringWidth of the sidebar250px
collapsedWidthnumber | stringWidth of the sidebar on collapsed state80px
backgroundColorstringSet background color for sidebarrgb(249, 249, 249, 0.7)
imagestringUrl of the image to use in the sidebar background, need to apply transparency to background color -
breakPointxs | sm | md | lg | xl | xxl | all | stringSet when the sidebar should trigger responsiveness behavior. Accepts a predefined breakpoint or a custom CSS value (ex: 450px)-
transitionDurationnumberDuration for the transition in milliseconds to be used in collapse and toggle behavior300
rtlbooleanRTL directionfalse
rootStylesCSSObjectApply styles to sidebar element-
onBackdropClick() => voidCallback function to be called when backdrop is clicked-
onBreakPoint(broken: boolean) => voidCallback function to be called when the broken state changes-
MenucloseOnClickbooleanIf true and sidebar is in collapsed state, submenu popper will automatically close on MenuItem clickfalse
popoverbooleanIf true, top-level SubMenus open as floating poppers even when the sidebar is expanded (instead of sliding open inline)false
accordionbooleanIf true, only one top-level SubMenu can be open at a time; opening another closes the previously open onefalse
menuItemStylesMenuItemStylesApply styles to MenuItem and SubMenu components and their children -
renderExpandIcon(params: { level: number; disabled: boolean; active: boolean; open: boolean; }) => React.ReactNodeRender method for customizing submenu expand icon-
transitionDurationnumberTransition duration in milliseconds to use when sliding submenu content300
rootStylesCSSObjectApply styles from Menu root element-
MenuItemiconReactNodeIcon for the menu item -
activebooleanIf true, the component is activefalse
disabledbooleanIf true, the component is disabled -
prefixReactNodeAdd a prefix to the menuItem -
suffixReactNodeAdd a suffix to the menuItem -
componentstring | ReactElementA component used for menu button node, can be string (ex: 'div') or a component -
rootStylesCSSObjectApply styles to MenuItem element-
SubMenulabelstring | ReactNodeLabel for the submenu -
iconReactNodeIcon for submenu-
defaultOpenbooleanSet if the submenu is open by defaultfalse
openbooleanSet open value if you want to control the state-
activebooleanIf true, the component is active. Also set automatically when any descendant is activefalse
disabledbooleanIf true, the component is disabled -
prefixReactNodeAdd a prefix to the submenu -
suffixReactNodeAdd a suffix to the submenu -
accordionbooleanIf true, only one of this submenu's direct child SubMenus can be open at a timefalse
onOpenChange(open: boolean) => voidCallback function called when submenu state changes-
componentstring | React.ReactElementA component used for menu button node, can be string (ex: 'div') or a component -
rootStylesCSSObjectApply styles to SubMenu element-

License

MIT © Mohamed Azouaoui

dropdown-menus
menu
menus
npm
npm-package
react
react-component
reactjs
sidebar
submenu
submenus
tree-structure

Project health

Overall

3.7/10

Maintained

0/10

Code review

0/10
OpenSSF Scorecard

Latest release

2.0.0-alpha.0 · May 25, 2026

Releases this year

0

Significant stargazers

May Kittens Devour Your Soul

261 followers · starred Sep 2023

Virat Singh

4,063 followers · starred Oct 2021

Mihai C

21 followers · starred Feb 2021

JP Erasmus

45 followers · starred Feb 2024