react-split-pane vs react-dock vs react-resize-panel
React Layout Management Libraries Comparison
1 Year
react-split-panereact-dockreact-resize-panelSimilar Packages:
What's React Layout Management Libraries?

React layout management libraries are designed to facilitate the creation of responsive and dynamic user interfaces by providing components that handle layout arrangements, resizing, and docking behavior. These libraries help developers build applications that can adapt to various screen sizes and user interactions, enhancing the overall user experience. They simplify the complexity of managing layout states and interactions, allowing developers to focus more on application logic rather than the intricacies of layout management.

Package Weekly Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
react-split-pane142,8343,244-1665 years agoMIT
react-dock61,62914,11835.8 kB20310 months agoMIT
react-resize-panel4,185---5 years ago-
Feature Comparison: react-split-pane vs react-dock vs react-resize-panel

Docking Capabilities

  • react-split-pane:

    react-split-pane allows for split views but does not support docking. It enables users to resize the panes but does not provide the flexibility to dock them to different positions.

  • react-dock:

    react-dock provides advanced docking capabilities, allowing panels to be docked to different edges of the container or floated freely. This flexibility is crucial for applications that require a customizable workspace, enabling users to arrange their interface according to their workflow.

  • react-resize-panel:

    react-resize-panel does not offer docking features; it focuses solely on resizing functionality. Users can resize panels, but they cannot dock them to specific edges or rearrange them in a floating manner.

Ease of Use

  • react-split-pane:

    react-split-pane is also user-friendly, with a simple API that allows developers to create split views easily. It strikes a balance between functionality and ease of use.

  • react-dock:

    react-dock has a steeper learning curve due to its more complex API and the need to manage docking states. However, it provides extensive customization options for developers willing to invest time in understanding its features.

  • react-resize-panel:

    react-resize-panel is straightforward to implement, making it easy for developers to add resizable panels with minimal configuration. Its simplicity is a significant advantage for quick implementations.

Customization

  • react-split-pane:

    react-split-pane allows for some customization of the split bar and pane styles, but it is limited compared to react-dock. It is designed for straightforward implementations rather than extensive customization.

  • react-dock:

    react-dock offers extensive customization options, allowing developers to define the appearance and behavior of docked panels. This includes styling, animations, and the ability to create custom docking layouts, making it highly adaptable to various use cases.

  • react-resize-panel:

    react-resize-panel provides basic customization for the resizing handles and panel styles but is less flexible than react-dock in terms of layout configurations. It is primarily focused on resizing rather than layout management.

Performance

  • react-split-pane:

    react-split-pane is also lightweight and performs efficiently, allowing for smooth resizing of panes without significant performance impacts. It is designed to handle user interactions fluidly.

  • react-dock:

    react-dock may introduce performance overhead due to its complex state management for docking behavior, especially with many panels. However, it is optimized for handling multiple panels efficiently when configured correctly.

  • react-resize-panel:

    react-resize-panel is lightweight and performs well, as it focuses solely on resizing without additional overhead from docking logic. It is suitable for applications where performance is critical and resizing is the primary concern.

Use Cases

  • react-split-pane:

    react-split-pane is perfect for applications that require side-by-side content display, such as file explorers, comparison tools, or any scenario where a split view enhances user experience.

  • react-dock:

    react-dock is ideal for applications that require a highly customizable workspace, such as IDEs, dashboards, or any application where users need to manage multiple panels dynamically.

  • react-resize-panel:

    react-resize-panel is best suited for applications where users need to customize panel sizes, such as design tools, layout editors, or any interface that benefits from adjustable panel dimensions.

How to Choose: react-split-pane vs react-dock vs react-resize-panel
  • react-split-pane:

    Opt for react-split-pane if you need a straightforward solution for creating split views where users can resize the panes. It is particularly useful for applications that require side-by-side content display, such as file explorers or comparison tools.

  • react-dock:

    Choose react-dock if you need a docking layout system that allows panels to be docked, floated, or tabbed. It is ideal for applications that require a customizable workspace, such as IDEs or dashboards, where users can rearrange panels according to their preferences.

  • react-resize-panel:

    Select react-resize-panel if your primary requirement is to create resizable panels that can adjust their size dynamically. This package is suitable for applications where user customization of panel sizes is essential, such as in design tools or layout editors.

README for react-split-pane

React Split Pane

NPM version NPM license NPM total downloads NPM monthly downloads Build Test Coverage Status

Split-Pane React component, can be nested or split vertically or horizontally!

Installing

npm install react-split-pane

# or if you use yarn

yarn add react-split-pane

## Example Usage

```jsx
<SplitPane split="vertical" minSize={50} defaultSize={100}>
  <div />
  <div />
</SplitPane>
<SplitPane split="vertical" minSize={50}>
  <div />
  <SplitPane split="horizontal">
    <div />
    <div />
  </SplitPane>
</SplitPane>

Props

primary

By dragging 'draggable' surface you can change size of the first pane. The first pane keeps then its size while the second pane is resized by browser window. By default it is the left pane for 'vertical' SplitPane and the top pane for 'horizontal' SplitPane. If you want to keep size of the second pane and let the first pane to shrink or grow by browser window dimensions, set SplitPane prop primary to second. In case of 'horizontal' SplitPane the height of bottom pane remains the same.

Resizing can be disabled by passing the allowResize prop as false (allowResize={false}). Resizing is enabled by default.

You can also set the size of the pane using the size prop. Note that a size set through props ignores the defaultSize and minSize properties.

In this example right pane keeps its width 200px while user is resizing browser window.

<SplitPane split="vertical" defaultSize={200} primary="second">
  <div />
  <div />
</SplitPane>

maxSize

You can limit the maximal size of the 'fixed' pane using the maxSize parameter with a positive value (measured in pixels but state just a number). If you wrap the SplitPane into a container component (yes you can, just remember the container has to have the relative or absolute positioning), then you'll need to limit the movement of the splitter (resizer) at the end of the SplitPane (otherwise it can be dragged outside the SplitPane and you don't catch it never more). For this purpose use the maxSize parameter with value 0. When dragged the splitter/resizer will stop at the border of the SplitPane component and think this you'll be able to pick it again and drag it back then. And more: if you set the maxSize to negative value (e.g. -200), then the splitter stops 200px before the border (in other words it sets the minimal size of the 'resizable' pane in this case). This can be useful also in the full-screen case of use.

step

You can use the step prop to only allow resizing in fixed increments.

onDragStarted

This callback is invoked when a drag starts.

onDragFinished

This callback is invoked when a drag ends.

onChange

This callback is invoked with the current drag during a drag event. It is recommended that it is wrapped in a debounce function.

Inline Styles

You can also pass inline styles to the components via props. These are:

  • style - Styling to be applied to the main container.
  • paneStyle - Styling to be applied to both panes
  • pane1Style - Styling to be applied to the first pane, with precedence over paneStyle
  • pane2Style - Styling to be applied to the second pane, with precedence over paneStyle
  • resizerStyle - Styling to be applied to the resizer bar

Persisting Positions

Each SplitPane accepts an onChange function prop. Used in conjunction with defaultSize and a persistence layer, you can ensure that your splitter choices survive a refresh of your app.

For example, if you are comfortable with the trade-offs of localStorage, you could do something like the following:

<SplitPane
  split="vertical"
  minSize={50}
  defaultSize={parseInt(localStorage.getItem('splitPos'), 10)}
  onChange={(size) => localStorage.setItem('splitPos', size)}
>
  <div />
  <div />
</SplitPane>

Disclaimer: localStorage has a variety of performance trade-offs. Browsers such as Firefox have now optimized localStorage use so that they will asynchronously initiate a read of all saved localStorage data for an origin once they know the page will load. If the data has not fully loaded by the time code accesses localStorage, the code will cause the page's main thread to block until the database load completes. When the main thread is blocked, no other JS code will run or layout will occur. In multiprocess browsers and for users with fast disk storage, this will be less of a problem. You are likely to get yelled at if you use localStorage.

A potentially better idea is to use something like https://github.com/mozilla/localForage although hooking it up will be slightly more involved. You are likely to be admired by all for judiciously avoiding use of localStorage.

Example styling

This gives a single pixel wide divider, but with a 'grabbable' surface of 11 pixels.

Thanks to background-clip: padding-box; for making transparent borders possible.

.Resizer {
  background: #000;
  opacity: 0.2;
  z-index: 1;
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  -moz-background-clip: padding;
  -webkit-background-clip: padding;
  background-clip: padding-box;
}

.Resizer:hover {
  -webkit-transition: all 2s ease;
  transition: all 2s ease;
}

.Resizer.horizontal {
  height: 11px;
  margin: -5px 0;
  border-top: 5px solid rgba(255, 255, 255, 0);
  border-bottom: 5px solid rgba(255, 255, 255, 0);
  cursor: row-resize;
  width: 100%;
}

.Resizer.horizontal:hover {
  border-top: 5px solid rgba(0, 0, 0, 0.5);
  border-bottom: 5px solid rgba(0, 0, 0, 0.5);
}

.Resizer.vertical {
  width: 11px;
  margin: 0 -5px;
  border-left: 5px solid rgba(255, 255, 255, 0);
  border-right: 5px solid rgba(255, 255, 255, 0);
  cursor: col-resize;
}

.Resizer.vertical:hover {
  border-left: 5px solid rgba(0, 0, 0, 0.5);
  border-right: 5px solid rgba(0, 0, 0, 0.5);
}
.Resizer.disabled {
  cursor: not-allowed;
}
.Resizer.disabled:hover {
  border-color: transparent;
}

New Version

I'm working on an updated version of this library, and looking for help:

Demo

http://react-split-pane-v2.surge.sh/

Install

npm install react-split-pane@next

# or if you use yarn

yarn add react-split-pane@next

Usage

import SplitPane, { Pane } from 'react-split-pane';

<SplitPane split="vertical">
  <Pane initialSize="200px">You can use a Pane component</Pane>
  <div>or you can use a plain old div</div>
  <Pane initialSize="25%" minSize="10%" maxSize="500px">
    Using a Pane allows you to specify any constraints directly
  </Pane>
</SplitPane>;

Pull request

https://github.com/tomkp/react-split-pane/pull/240

More discussion

https://github.com/tomkp/react-split-pane/issues/233

Contributing

I'm always happy to receive Pull Requests for contributions of any kind.

Please include tests and/or update the examples if possible.

Thanks, Tom