zesik / react-splitter-layout

A simple split layout for React and modern browsers. https://zesik.com/react-splitter-layout
MIT License
422 stars 128 forks source link

react-splitter-layout

Travis Coveralls npm License David devDependencies David peerDependencies

A simple split layout for React and modern browsers.

Demo

Dependencies

React-splitter-layout depends on React and prop-types. See package.json for more details.

Installation

$ npm install --save react-splitter-layout

Testing

To start example server, execute example script with npm.

$ npm run example

To run tests, execute test command with npm.

$ npm test

To run coverage tests, execute coverage script with npm.

$ npm run coverage

Integration

  1. Add react-splitter-layout dependency to your code.

    $ npm install --save react-splitter-layout
  2. Include the library into your code and use it.

    import React from 'react';
    import SplitterLayout from 'react-splitter-layout';
    import 'react-splitter-layout/lib/index.css';
    
    class YourComponent extends React.Component {
      render() {
        return (
          <SplitterLayout>
            <div>Pane 1</div>
            <div>Pane 2</div>
          </SplitterLayout>
        );
      }
    }
    
    export default YourComponent;

Note: From version 4.0.0, you need to import CSS files or handle it in your favorite way explicitly.

Usage

Write two parts of the layout as direct children of your SplitterLayout element. SplitterLayout renders the first 2 direct children only if it has more than 2 direct children. SplitterLayout does not render splitter when it has only 1 direct children, and the only direct children occupies all available space.

The SplitterLayout component supports the following props.

Release History

License

MIT