react-resizable-panels vs react-grid-layout vs react-split-pane vs react-splitter-layout
React Layout Management Libraries Comparison
1 Year
react-resizable-panelsreact-grid-layoutreact-split-panereact-splitter-layoutSimilar Packages:
What's React Layout Management Libraries?

These libraries provide various functionalities for creating responsive and flexible layouts in React applications. They allow developers to create grid-based layouts, resizable panels, and split views that enhance user experience by enabling dynamic content organization. Each library has unique features tailored to different layout needs, making it essential to understand their capabilities for effective implementation in web applications.

Package Weekly Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
react-resizable-panels4,144,9584,444526 kB95 days agoMIT
react-grid-layout742,99321,183527 kB2402 months agoMIT
react-split-pane171,7473,265-1675 years agoMIT
react-splitter-layout14,575431-386 years agoMIT
Feature Comparison: react-resizable-panels vs react-grid-layout vs react-split-pane vs react-splitter-layout

Layout Flexibility

  • react-resizable-panels:

    react-resizable-panels provides a straightforward API for creating resizable panels, allowing users to adjust panel sizes easily without complex configurations, focusing on simplicity and usability.

  • react-grid-layout:

    react-grid-layout offers a highly flexible grid system that allows for both draggable and resizable grid items, making it perfect for applications that require user-customizable layouts such as dashboards.

  • react-split-pane:

    react-split-pane allows for the creation of split views where users can resize the panes, making it ideal for applications that need a clear division of content while maintaining a user-friendly interface.

  • react-splitter-layout:

    react-splitter-layout offers advanced features for creating splitter layouts, including customizable styles and behaviors, allowing for a more tailored user experience in complex applications.

Ease of Use

  • react-resizable-panels:

    react-resizable-panels is designed for ease of use, with a minimal setup required to create resizable panels, making it accessible for developers of all skill levels.

  • react-grid-layout:

    react-grid-layout has a steeper learning curve due to its extensive feature set, but it provides comprehensive documentation and examples to help developers get started quickly.

  • react-split-pane:

    react-split-pane is relatively easy to implement, with a simple API that allows developers to create split views with minimal effort, making it suitable for quick implementations.

  • react-splitter-layout:

    react-splitter-layout requires a bit more configuration compared to others but offers greater flexibility, making it suitable for developers who need advanced layout capabilities.

Customization

  • react-resizable-panels:

    react-resizable-panels offers basic customization for panel sizes and behaviors, but it is primarily focused on simplicity rather than extensive customization options.

  • react-grid-layout:

    react-grid-layout provides extensive customization options for grid items, including responsive breakpoints and layout configurations, allowing developers to create highly tailored layouts.

  • react-split-pane:

    react-split-pane allows for some customization of the split pane sizes and styles, making it easy to adapt to different design requirements without heavy modifications.

  • react-splitter-layout:

    react-splitter-layout excels in customization, allowing developers to define styles and behaviors for splitters, making it ideal for applications needing a unique look and feel.

Performance

  • react-resizable-panels:

    react-resizable-panels is lightweight and performs well for simple use cases, but may not be as efficient for complex layouts with many resizable panels.

  • react-grid-layout:

    react-grid-layout is optimized for performance with efficient rendering of grid items, but can become complex with a large number of items, requiring careful management of state and props.

  • react-split-pane:

    react-split-pane is performant for most use cases, but performance can degrade with excessive nested panes, necessitating optimization strategies for large applications.

  • react-splitter-layout:

    react-splitter-layout is designed for performance with minimal overhead, but developers should be mindful of rendering performance when dealing with complex layouts.

Community and Support

  • react-resizable-panels:

    react-resizable-panels has a smaller community but offers good documentation and examples, making it easy to find support for common issues.

  • react-grid-layout:

    react-grid-layout has a large community and extensive documentation, providing ample resources for troubleshooting and implementation guidance.

  • react-split-pane:

    react-split-pane is widely used and has a decent community presence, ensuring that developers can find help and resources when needed.

  • react-splitter-layout:

    react-splitter-layout has a growing community with increasing support, but may not have as many resources available compared to more established libraries.

How to Choose: react-resizable-panels vs react-grid-layout vs react-split-pane vs react-splitter-layout
  • react-resizable-panels:

    Opt for react-resizable-panels if your application requires a simple and intuitive way to create resizable panels, focusing on ease of use and minimal configuration.

  • react-grid-layout:

    Choose react-grid-layout if you need a powerful grid system that supports draggable and resizable grid items, ideal for dashboard-like interfaces where users can customize their layout.

  • react-split-pane:

    Select react-split-pane for a straightforward solution to create split views with adjustable sizes, particularly useful for applications that need a clear separation of content areas.

  • react-splitter-layout:

    Use react-splitter-layout if you need a more advanced splitter layout with customizable styles and features, suitable for complex applications that require a high degree of control over layout behavior.

README for react-resizable-panels

react-resizable-panels

React components for resizable panel groups/layouts

import { Panel, PanelGroup, PanelResizeHandle } from "react-resizable-panels";

<PanelGroup autoSaveId="example" direction="horizontal">
  <Panel defaultSize={25}>
    <SourcesExplorer />
  </Panel>
  <PanelResizeHandle />
  <Panel>
    <SourceViewer />
  </Panel>
  <PanelResizeHandle />
  <Panel defaultSize={25}>
    <Console />
  </Panel>
</PanelGroup>;

If you like this project, 🎉 become a sponsor or ☕ buy me a coffee

Props

PanelGroup

| prop | type | description | | :----------- | :--------------------------- | :--------------------------------------------------------------- | | autoSaveId | ?string | Unique id used to auto-save group arrangement via localStorage | | children | ReactNode | Arbitrary React element(s) | | className | ?string | Class name to attach to root element | | direction | "horizontal" \| "vertical" | Group orientation | | id | ?string | Group id; falls back to useId when not provided | | onLayout | ?(sizes: number[]) => void | Called when group layout changes | | storage | ?PanelGroupStorage | Custom storage API; defaults to localStorage 1 | | style | ?CSSProperties | CSS style to attach to root element | | tagName | ?string = "div" | HTML element tag name for root element |

1: Storage API must define the following synchronous methods:

  • getItem: (name:string) => string
  • setItem: (name: string, value: string) => void

PanelGroup components also expose an imperative API for manual resizing: | method | description | | :---------------------------- | :--------------------------------------------------------------- | | getId(): string | Gets the panel group's ID. | | getLayout(): number[] | Gets the panel group's current layout ([1 - 100, ...]). | | setLayout(layout: number[]) | Resize panel group to the specified layout ([1 - 100, ...]). |

Panel

| prop | type | description | | :-------------- | :------------------------ | :-------------------------------------------------------------------------------------------- | | children | ReactNode | Arbitrary React element(s) | | className | ?string | Class name to attach to root element | | collapsedSize | ?number=0 | Panel should collapse to this size | | collapsible | ?boolean=false | Panel should collapse when resized beyond its minSize | | defaultSize | ?number | Initial size of panel (numeric value between 1-100) | | id | ?string | Panel id (unique within group); falls back to useId when not provided | | maxSize | ?number = 100 | Maximum allowable size of panel (numeric value between 1-100); defaults to 100 | | minSize | ?number = 10 | Minimum allowable size of panel (numeric value between 1-100); defaults to 10 | | onCollapse | ?() => void | Called when panel is collapsed | | onExpand | ?() => void | Called when panel is expanded | | onResize | ?(size: number) => void | Called when panel is resized; size parameter is a numeric value between 1-100. 1 | | order | ?number | Order of panel within group; required for groups with conditionally rendered panels | | style | ?CSSProperties | CSS style to attach to root element | | tagName | ?string = "div" | HTML element tag name for root element |

1: If any Panel has an onResize callback, the order prop should be provided for all Panels.

Panel components also expose an imperative API for manual resizing: | method | description | | :----------------------- | :--------------------------------------------------------------------------------- | | collapse() | If panel is collapsible, collapse it fully. | | expand() | If panel is currently collapsed, expand it to its most recent size. | | getId(): string | Gets the ID of the panel. | | getSize(): number | Gets the current size of the panel as a percentage (1 - 100). | | isCollapsed(): boolean | Returns true if the panel is currently collapsed (size === 0). | | isExpanded(): boolean | Returns true if the panel is currently not collapsed (!isCollapsed()). | | getSize(): number | Returns the most recently committed size of the panel as a percentage (1 - 100). | | resize(size: number) | Resize panel to the specified percentage (1 - 100). |

PanelResizeHandle

| prop | type | description | | :--------------- | :-------------------------------------------- | :------------------------------------------------------------------------------ | | children | ?ReactNode | Custom drag UI; can be any arbitrary React element(s) | | className | ?string | Class name to attach to root element | | hitAreaMargins | ?{ coarse: number = 15; fine: number = 5; } | Allow this much margin when determining resizable handle hit detection | | disabled | ?boolean | Disable drag handle | | id | ?string | Resize handle id (unique within group); falls back to useId when not provided | | onDragging | ?(isDragging: boolean) => void | Called when group layout changes | | style | ?CSSProperties | CSS style to attach to root element | | tagName | ?string = "div" | HTML element tag name for root element |


FAQ

Can panel sizes be specified in pixels?

No. Pixel-based constraints added significant complexity to the initialization and validation logic and so I've decided not to support them. You may be able to implement a version of this yourself following a pattern like this but it is not officially supported by this library.

How can I fix layout/sizing problems with conditionally rendered panels?

The Panel API doesn't require id and order props because they aren't necessary for static layouts. When panels are conditionally rendered though, it's best to supply these values.

<PanelGroup direction="horizontal">
  {renderSideBar && (
    <>
      <Panel id="sidebar" minSize={25} order={1}>
        <Sidebar />
      </Panel>
      <PanelResizeHandle />
    </>
  )}
  <Panel minSize={25} order={2}>
    <Main />
  </Panel>
</PanelGroup>

Can a attach a ref to the DOM elements?

No. I think exposing two refs (one for the component's imperative API and one for a DOM element) would be awkward. This library does export several utility methods for accessing the underlying DOM elements though. For example:

import {
  getPanelElement,
  getPanelGroupElement,
  getResizeHandleElement,
  Panel,
  PanelGroup,
  PanelResizeHandle,
} from "react-resizable-panels";

export function Example() {
  const refs = useRef();

  useEffect(() => {
    const groupElement = getPanelGroupElement("group");
    const leftPanelElement = getPanelElement("left-panel");
    const rightPanelElement = getPanelElement("right-panel");
    const resizeHandleElement = getResizeHandleElement("resize-handle");

    // If you want to, you can store them in a ref to pass around
    refs.current = {
      groupElement,
      leftPanelElement,
      rightPanelElement,
      resizeHandleElement,
    };
  }, []);

  return (
    <PanelGroup direction="horizontal" id="group">
      <Panel id="left-panel">{/* ... */}</Panel>
      <PanelResizeHandle id="resize-handle" />
      <Panel id="right-panel">{/* ... */}</Panel>
    </PanelGroup>
  );
}

Why don't I see any resize UI?

This likely means that you haven't applied any CSS to style the resize handles. By default, a resize handle is just an empty DOM element. To add styling, use the className or style props:

// Tailwind example
<PanelResizeHandle className="w-2 bg-blue-800" />

Can panel sizes be persistent?

Yes. Panel groups with an autoSaveId prop will automatically save and restore their layouts on mount.

How can I use persistent layouts with SSR?

By default, this library uses localStorage to persist layouts. With server rendering, this can cause a flicker when the default layout (rendered on the server) is replaced with the persisted layout (in localStorage). The way to avoid this flicker is to also persist the layout with a cookie like so:

Server component

import ResizablePanels from "@/app/ResizablePanels";
import { cookies } from "next/headers";

export function ServerComponent() {
  const layout = cookies().get("react-resizable-panels:layout");

  let defaultLayout;
  if (layout) {
    defaultLayout = JSON.parse(layout.value);
  }

  return <ClientComponent defaultLayout={defaultLayout} />;
}

Client component

"use client";

import { Panel, PanelGroup, PanelResizeHandle } from "react-resizable-panels";

export function ClientComponent({
  defaultLayout = [33, 67],
}: {
  defaultLayout: number[] | undefined;
}) {
  const onLayout = (sizes: number[]) => {
    document.cookie = `react-resizable-panels:layout=${JSON.stringify(sizes)}`;
  };

  return (
    <PanelGroup direction="horizontal" onLayout={onLayout}>
      <Panel defaultSize={defaultLayout[0]}>{/* ... */}</Panel>
      <PanelResizeHandle className="w-2 bg-blue-800" />
      <Panel defaultSize={defaultLayout[1]}>{/* ... */}</Panel>
    </PanelGroup>
  );
}

[!NOTE] Be sure to specify a defaultSize prop for every Panel component to avoid layout flicker.

A demo of this is available here.

How can I set the CSP "nonce" attribute?

import { setNonce } from "react-resizable-panels";

setNonce("your-nonce-value-here");

How can I disable global cursor styles?

import { disableGlobalCursorStyles } from "react-resizable-panels";

disableGlobalCursorStyles();