react-resizable-panels provides a robust and accessible solution for building resizable panel groups and layouts in React applications. Currently at version 4.10.0, the library maintains an active development pace with frequent patch and minor releases, reflecting ongoing enhancements and bug fixes. Key differentiators include flexible size constraints supporting various units (pixels, percentages, REMs/EMs, viewport units), improved server-side rendering support for both traditional SSR and React Server Components, and a declarative API complemented by imperative escape hatches via refs. It focuses on smooth user interactions with drag, double-click to reset, and keyboard accessibility for resizing, making it suitable for complex UIs like IDEs or dashboards. The library also supports persistent layouts via `useDefaultLayout` and offers granular control over resize behavior, building on a foundation of performance and robustness by its author.
npm install react-resizable-panelsVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates a nested resizable layout using `Group`, `Panel`, and `Separator` components, showcasing horizontal and vertical orientations and how to handle layout changes.
Update imports from `PanelGroup` to `Group` and `PanelResizeHandle` to `Separator`. Change `direction="horizontal"` or `direction="vertical"` to `orientation="horizontal"` or `orientation="vertical"` respectively.
Update CSS selectors and accessibility checks to target `[data-disabled='true']` instead of `[aria-disabled='true']` for `Panel` components.
Avoid attempting to override these specific CSS properties directly on the `Group` component's `style` prop. Adjust parent container styles or wrap `Group` in another `div` for layout adjustments if necessary.
For persistent layout saving or actions that should occur once per resize operation, use the `onLayoutChanged` callback instead, which fires only after the pointer has been released.
Refer to the official documentation for strategies to minimize SSR layout shift, which often involves pre-calculating pixel sizes or using a loading state.
While `useDefaultLayout` handles migration, review the migration guide from v3 to v4 for API changes (e.g., `onCollapse`/`onExpand` removed, `direction` to `orientation`, `PanelResizeHandle` to `Separator`) if manually managing or debugging layout persistence.
Upgrade to `react-resizable-panels@4.0.12` or higher, where `useDefaultLayout` now defaults to debouncing `storage.setItem` calls by 150ms. If you require immediate saving for specific scenarios (e.g., unit tests), you can explicitly set `debounceSaveMs: 0` in the `useDefaultLayout` options.
Change `import { PanelGroup } from 'react-resizable-panels';` to `import { Group } from 'react-resizable-panels';`Change `import { PanelResizeHandle } from 'react-resizable-panels';` to `import { Separator } from 'react-resizable-panels';`Ensure that `Group` components directly contain `Panel` and `Separator` components, and that `Panel` components contain a single React element as their child content.
Use the `onLayoutChanged` prop on the `Group` component for saving the layout, as it fires reliably after a resize operation is complete. For automatic persistence, ensure `useDefaultLayout` is configured correctly with an `id` and `storage` mechanism.