API Reference

Complete prop reference for every component exported by react-pro-sidebar. For guided examples and a deeper walkthrough per component, see the Components docs.

Props marked New in v2 were introduced in the upcoming 2.0.0 release. See the Changelog and Migration Guide for details.

The root container that holds the sidebar’s structure, controls collapse/toggle state, and provides theming.

PropTypeDefaultDescription
collapsedbooleanfalseSidebar collapsed state
toggledbooleanfalseSidebar toggled (open) state when broken/overlay
widthstring'250px'Width of the sidebar
collapsedWidthstring'80px'Width when collapsed
backgroundColorstring'rgb(249, 249, 249, 0.7)'Sidebar background color
imagestringURL of a background image (apply alpha to backgroundColor for visibility)
breakPoint'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl' | 'all' | stringBreakpoint at which the sidebar switches to overlay mode; accepts a predefined value or a custom CSS length (e.g. '450px')
transitionDurationnumber300Transition duration in milliseconds
rtlbooleanfalseRight-to-left direction
rootStylesCSSObjectApply styles to the sidebar root element
onBackdropClick() => voidCalled when the overlay backdrop is clicked
onBreakPoint(broken: boolean) => voidCalled when the broken state changes

Behaviors added in v2

  • Pressing Escape now closes the sidebar when open as an overlay (broken + toggled).
  • Focus moves into the sidebar when it opens as an overlay, so keyboard users land inside it.
  • Backdrop now uses onKeyDown and activates only on Enter / Space (no longer fires on any key).

Container for MenuItem and SubMenu children. Holds the styling system (menuItemStyles), accordion coordination, and the global popover mode.

PropTypeDefaultDescription
closeOnClickbooleanfalseIf true and the sidebar is collapsed, submenu popper closes on MenuItem click
popoverbooleanfalseNew in v2. If true, top-level SubMenus open as floating poppers even when expanded
accordionbooleanfalseNew in v2. If true, only one top-level SubMenu can be open at a time
menuItemStylesMenuItemStylesApply styles to MenuItem/SubMenu and their child slots (root, button, label, icon, prefix, suffix, …)
renderExpandIcon(params) => ReactNodeCustom render for the SubMenu expand icon. params: { level, collapsed, disabled, active, open }
transitionDurationnumber300Transition duration for sliding submenu content
rootStylesCSSObjectApply styles to the Menu root element

A single clickable item inside a Menu. Can be rendered as any element via component for routing integrations.

PropTypeDefaultDescription
iconReactNodeIcon node displayed before the label
activebooleanfalseActive state
disabledbooleanfalseDisabled state
prefixReactNodeNode displayed between the icon and the label
suffixReactNodeNode displayed after the label
componentstring | ReactElementComponent used for the button node (e.g. 'div', <NavLink to="..." />)
rootStylesCSSObjectApply styles to the MenuItem root

Accessibility added in v2

  • aria-current="page" is set on active items.
  • aria-disabled is set on disabled items.

A nestable container that opens to reveal child MenuItem / SubMenu nodes. Cascades active state from descendants automatically.

PropTypeDefaultDescription
labelstring | ReactNodeLabel displayed for the submenu trigger
iconReactNodeIcon node displayed before the label
defaultOpenbooleanfalseInitial open state (uncontrolled)
openbooleanControlled open state
activebooleanfalseForced active state (the submenu is also active automatically when any descendant is active)
disabledbooleanfalseDisabled state
prefixReactNodeNode displayed between the icon and the label
suffixReactNodeNode displayed after the label
accordionbooleanfalseNew in v2. Only one of this SubMenu’s direct child SubMenus can be open at a time
onOpenChange(open: boolean) => voidCalled when the open state changes
componentstring | ReactElementComponent used for the trigger button
rootStylesCSSObjectApply styles to the SubMenu root

Behaviors added in v2

  • Active state now cascades automatically: a SubMenu is marked active whenever any descendant is active.
  • Items in a closed submenu are no longer reachable via Tab or exposed to screen readers — closed content is now marked inert.
  • The trigger now uses role="button" so aria-expanded / aria-haspopup are valid.
  • aria-expanded on the trigger, aria-haspopup="menu" when a collapsed top-level submenu opens as a popup, and aria-disabled on disabled triggers.

Utility classes

The package exports class-name registries that you can use as CSS selectors inside rootStyles or your own stylesheets.

import { sidebarClasses, menuClasses } from 'react-pro-sidebar';
RegistryKeys
sidebarClassesroot, container, image, backdrop, collapsed, toggled, rtl, broken
menuClassesroot, menuItemRoot, subMenuRoot, button, prefix, suffix, label, icon, subMenuContent, SubMenuExpandIcon, disabled, active, open

Types

import type { CSSObject } from 'react-pro-sidebar';
 
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);
 
interface MenuItemStylesParams {
  level: number;
  disabled: boolean;
  active: boolean;
  isSubmenu: boolean;
  open?: boolean;
}