Split-Pane component that stores it's position to localStorage. Fires window resize event on resize to notify other components that container size has changed. Uses react-split-pane component, check out more complex usage there.
npm install @opuscapita/react-splitpane
View the DEMO
The default build with compiled styles in the .js file. Also minified version available in the lib/umd directory.
You need to configure your module loader to use cjs
or es
fields of the package.json to use these module types.
Also you need to configure sass loader, since all the styles are in sass format.
- With webpack use resolve.mainFields to configure the module type.
- Add SASS loader to support importing of SASS styles.
Prop name | Type | Default | Description |
---|---|---|---|
id | string (required) | Unique ID of the component | |
split | string | 'vertical' | Split direction 'vertical' or 'horizontal' |
minSize | string, number | 50 | Current size of the pane |
defaultSize | string, number | '50%' | Initial size of the pane |
rememberSize | boolean | true | Store size to localStorage |
import React from 'react';
import SplitPane from '@opuscapita/react-splitpane';
handleResize = (id, size) => {
console.log(id, 'changed size to', size);
}
export default class ReactView extends React.Component {
render() {
return (
<SplitPane id="myVerticalPane">
<div></div>
<SplitPane id="myHorizontalPane" split="horizontal">
<div></div>
<div></div>
</SplitPane>
</SplitPane>
);
}
}