react-resizable vs react-split-pane vs react-splitter-layout
React Resizable and Split Layout Libraries Comparison
1 Year
react-resizablereact-split-panereact-splitter-layoutSimilar Packages:
What's React Resizable and Split Layout Libraries?

These libraries provide functionalities for creating resizable and split layouts in React applications. They enable developers to create dynamic user interfaces where components can be resized or split into multiple sections, enhancing user experience and flexibility. Each library offers unique features and design principles that cater to different use cases, making it essential to understand their strengths and weaknesses when choosing one for your project.

Package Weekly Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
react-resizable1,053,3292,499116 kB782 years agoMIT
react-split-pane171,7473,265-1675 years agoMIT
react-splitter-layout14,575431-386 years agoMIT
Feature Comparison: react-resizable vs react-split-pane vs react-splitter-layout

Customization

  • react-resizable:

    react-resizable allows for extensive customization of resize handles and behavior. You can define specific constraints, such as minimum and maximum sizes, and customize the appearance of the resize handles to fit your application's design.

  • react-split-pane:

    react-split-pane provides built-in options for customizing the appearance of the split panes, including styles for the splitter and the ability to set default sizes for each pane. It also allows for controlled resizing with callbacks to manage state changes.

  • react-splitter-layout:

    react-splitter-layout offers a high degree of customization, including the ability to nest splitters and control their orientation. You can easily style the splitters and panes, and it supports complex layouts with multiple resizable sections.

Ease of Use

  • react-resizable:

    react-resizable is straightforward to implement, requiring minimal setup. Its API is simple, making it easy for developers to add resizing functionality to existing components without extensive configuration.

  • react-split-pane:

    react-split-pane is user-friendly and provides a clear API for creating split layouts. It handles resizing events internally, allowing developers to focus on layout logic rather than low-level event handling.

  • react-splitter-layout:

    react-splitter-layout is designed for developers who need more control over their layouts. While it may require a bit more setup compared to the others, its flexibility makes it suitable for complex applications.

Performance

  • react-resizable:

    react-resizable is lightweight and optimized for performance, ensuring that adding resizing capabilities does not significantly impact the application's overall performance. It efficiently handles resize events without unnecessary re-renders.

  • react-split-pane:

    react-split-pane is designed to maintain performance even with multiple panes. It minimizes re-renders and efficiently manages state changes, making it suitable for applications with dynamic content.

  • react-splitter-layout:

    react-splitter-layout is built with performance in mind, especially for applications with nested layouts. It efficiently handles multiple resize events and updates, ensuring a smooth user experience even with complex layouts.

Community and Support

  • react-resizable:

    react-resizable has a smaller community compared to the others, but it is well-documented and supported by the React ecosystem, making it easy to find resources and examples for implementation.

  • react-split-pane:

    react-split-pane has a moderate community and is widely used in various applications, providing a good amount of resources, tutorials, and community support for troubleshooting and enhancements.

  • react-splitter-layout:

    react-splitter-layout has a growing community and offers comprehensive documentation, making it easier for developers to find help and examples. Its flexibility has led to increased adoption in complex applications.

Integration

  • react-resizable:

    react-resizable can be easily integrated into existing components without requiring significant changes to your codebase. It works well with other libraries and frameworks, making it a versatile choice.

  • react-split-pane:

    react-split-pane integrates seamlessly with other React components, allowing for the creation of complex layouts without much hassle. It can be combined with state management libraries for enhanced functionality.

  • react-splitter-layout:

    react-splitter-layout is designed to work well with various layout libraries and can be easily integrated into applications that require complex UI structures. Its flexibility allows for creative combinations with other UI components.

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

    Choose react-resizable if you need a lightweight solution focused solely on making components resizable. It provides a simple API for adding resize handles to any component, allowing for fine-grained control over resizing behavior.

  • react-split-pane:

    Opt for react-split-pane if you require a more comprehensive solution that allows for splitting the UI into resizable panes. This library is ideal for applications that need a clear division of content, such as dashboards or editors, and supports vertical and horizontal splits with customizable styles.

  • react-splitter-layout:

    Select react-splitter-layout if you want a highly customizable and flexible layout system that supports multiple splitters and nested layouts. It is suitable for complex applications where you need to manage multiple resizable sections and offers advanced features like drag-and-drop support.

README for react-resizable

React-Resizable

View the Demo

A simple widget that can be resized via one or more handles.

You can either use the <Resizable> element directly, or use the much simpler <ResizableBox> element.

See the example and associated code in ExampleLayout and ResizableBox for more details.

Make sure you use the associated styles in /css/styles.css, as without them, you will have problems with handle placement and visibility.

You can pass options directly to the underlying DraggableCore instance by using the prop draggableOpts. See the demo for more on this.

Installation

$ npm install --save react-resizable

Compatibility

React-Resizable 3.x is compatible with React >= 16.3. React-Resizable 2.x has been skipped. React-Resizable 1.x is compatible with React 14-17.

Usage

This package has two major exports:

  • <Resizable>: A raw component that does not have state. Use as a building block for larger components, by listening to its callbacks and setting its props.
  • <ResizableBox>: A simple <div {...props} /> element that manages basic state. Convenient for simple use-cases.

<Resizable>

const {Resizable} = require('react-resizable');

// ES6
import { Resizable } from 'react-resizable';

// ...
class Example extends React.Component {
  state = {
    width: 200,
    height: 200,
  };

  // On top layout
  onResize = (event, {node, size, handle}) => {
    this.setState({width: size.width, height: size.height});
  };

  render() {
    return (
      <Resizable height={this.state.height} width={this.state.width} onResize={this.onResize}>
        <div className="box" style={{width: this.state.width + 'px', height: this.state.height + 'px'}}>
          <span>Contents</span>
        </div>
      </Resizable>
    );
  }
}

<ResizableBox>

const {ResizableBox} = require('react-resizable');

// ES6
import { ResizableBox } from 'react-resizable';

class Example extends React.Component {
  render() {
    return (
      <ResizableBox width={200} height={200} draggableOpts={{...}}
          minConstraints={[100, 100]} maxConstraints={[300, 300]}>
        <span>Contents</span>
      </ResizableBox>
    );
  }
}

Props

These props apply to both <Resizable> and <ResizableBox>. Unknown props that are not in the list below will be passed to the child component.

type ResizeCallbackData = {
  node: HTMLElement,
  size: {width: number, height: number},
  handle: ResizeHandleAxis
};
type ResizeHandleAxis = 's' | 'w' | 'e' | 'n' | 'sw' | 'nw' | 'se' | 'ne';

type ResizableProps =
{
  children: React.Element<any>,
  width: number,
  height: number,
  // Either a ReactElement to be used as handle, or a function returning an element that is fed the handle's location as its first argument.
  handle: ReactElement<any> | (resizeHandle: ResizeHandleAxis, ref: ReactRef<HTMLElement>) => ReactElement<any>,
  // If you change this, be sure to update your css
  handleSize: [number, number] = [10, 10],
  lockAspectRatio: boolean = false,
  axis: 'both' | 'x' | 'y' | 'none' = 'both',
  minConstraints: [number, number] = [10, 10],
  maxConstraints: [number, number] = [Infinity, Infinity],
  onResizeStop?: ?(e: SyntheticEvent, data: ResizeCallbackData) => any,
  onResizeStart?: ?(e: SyntheticEvent, data: ResizeCallbackData) => any,
  onResize?: ?(e: SyntheticEvent, data: ResizeCallbackData) => any,
  draggableOpts?: ?Object,
  resizeHandles?: ?Array<ResizeHandleAxis> = ['se']
};

The following props can also be used on <ResizableBox>:

{
  style?: Object // styles the returned <div />
}

If a width or height is passed to <ResizableBox>'s style prop, it will be ignored as it is required for internal function.

Resize Handle

If you override the resize handle, we expect that any ref passed to your new handle with represent the underlying DOM element.

This is required, as react-resizable must be able to access the underlying DOM node to attach handlers and measure position deltas.

There are a few ways to do this:

Native DOM Element

This requires no special treatment.

<Resizable handle={<div className="foo" />} />
Custom React Component

You must forward the ref and props to the underlying DOM element.

Class Components
class MyHandleComponent extends React.Component {
  render() {
    const {handleAxis, innerRef, ...props} = this.props;
    return <div ref={innerRef} className={`foo handle-${handleAxis}`} {...props} />
  }
}
const MyHandle = React.forwardRef((props, ref) => <MyHandleComponent innerRef={ref} {...props} />);

<Resizable handle={<MyHandle />} />
Functional Components
const MyHandle = React.forwardRef((props, ref) => {
  const {handleAxis, ...restProps} = props;
  return <div ref={ref} className={`foo handle-${handleAxis}`} {...restProps} />;
});

<Resizable handle={<MyHandle />} />
Custom Function

You can define a function as a handle, which will simply receive an axis (see above ResizeHandleAxis type) and ref. This may be more clear to read, depending on your coding style.

const MyHandle = (props) => {
  return <div ref={props.innerRef} className="foo" {...props} />;
};

<Resizable handle={(handleAxis, ref) => <MyHandle innerRef={ref} className={`foo handle-${handleAxis}`} {...props} />} />