Overview
React-collapse-pane is a React library that provides a simple and elegant solution for adding splittable, draggable, and collapsible panes to your React application. It aims to be reliable and configurable, allowing you to easily create layouts with collapsible panels.
Features
- Splittable, draggable, and collapsible panes
- Support for vertical and horizontal split orientations
- Ability to exclude specific children from being split or displayed
- Customizable styling for the resizer, buttons, and animations
- RTL (right-to-left) support
Installation
To install react-collapse-pane, follow these steps:
- Install the package using npm or yarn:
npm install react-collapse-pane
or
yarn add react-collapse-pane
- Import the SplitPane component in your code:
import { SplitPane } from 'react-collapse-pane';
- Use the SplitPane component as a wrapper for the children you wish to lay out. Specify the split prop to set the orientation of the split panel:
<SplitPane split="vertical">
{/* Your children components */}
</SplitPane>
Note: If you are using TypeScript, you can also import the SplitPaneProps type for additional helper types.
MUI v5 Peer Dependency
Since the upgrade to MUI v5, react-collapse-pane requires a peer dependency style engine. You can choose between styled components and emotion. Follow the appropriate configuration guide based on your choice:
- If you want to use the default style engine, follow the installation guide here.
- If you want to use styled components, follow the configuration guide here.
Please note that this dependency will be removed in future versions to reduce the size of the library.
Summary
React-collapse-pane is a reliable and configurable React library that allows you to easily create splittable, draggable, and collapsible panes in your React application. It provides customizable styling options, support for both vertical and horizontal splits, and the ability to exclude specific children from the split. The library also supports RTL (right-to-left) layouts and is compatible with MUI v5. With its simplicity and elegance, react-collapse-pane is a great choice for achieving flexible and customizable layouts in your React projects.