{"name":"react-split-pane","version":"3.1.0","keywords":["react","react-component","split-pane","react-split-pane","typescript","hooks","resizable","panes","layout","accessibility"],"author":{"name":"tomkp","email":"tom@tomkp.com"},"license":"MIT","_id":"react-split-pane@3.1.0","maintainers":[{"name":"tomkp","email":"tom@tomkp.com"},{"name":"wuweiweiwu","email":"me@weiweiwu.me"}],"homepage":"https://github.com/tomkp/react-split-pane#readme","bugs":{"url":"https://github.com/tomkp/react-split-pane/issues"},"dist":{"shasum":"423384767f1b423b985f7c5a3551c72c6579341c","tarball":"http://registry-npm.ywwl.com/react-split-pane/download/react-split-pane-3.1.0.tgz","fileCount":42,"integrity":"sha512-gHKn3Sczy3DJJ800+g+BKC6IA0XgKm/DpxRto27DV2vZA6tDe7JFVRYqOAElWFsrlozN3as4/ws1cJ0UaYmFnA==","signatures":[{"sig":"MEUCIQD9bOFYq3gZQAHpWTb+nRSMmEA/+ut3O6C+0y0s/2LhcwIgLBL21c72GJODFPYzu/F49yC4e17USWBFIODu7oqUkM8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":103247,"size":27503,"noattachment":false,"key":"/react-split-pane/-/react-split-pane-3.1.0.tgz"},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=20.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./keyboard":{"types":"./dist/keyboard.d.ts","import":"./dist/keyboard.js","require":"./dist/keyboard.cjs"},"./styles.css":"./styles.css","./persistence":{"types":"./dist/persistence.d.ts","import":"./dist/persistence.js","require":"./dist/persistence.cjs"}},"gitHead":"6cf8d8b1297610874d9fa4698ca651a7c8867a6f","scripts":{"dev":"rollup -c -w","lint":"eslint src","test":"vitest run","build":"rollup -c && npm run build:types","checks":"npm run typecheck && npm run lint && npm run format && npm run test","format":"prettier --write src examples","examples":"vite --config examples/vite.config.ts","typecheck":"tsc --noEmit","test:watch":"vitest","build:types":"tsc --emitDeclarationOnly","format:check":"prettier --check src examples","test:coverage":"vitest run --coverage","examples:build":"vite build --config examples/vite.config.ts","prepublishOnly":"npm run test && npm run build"},"_npmUser":{"name":"tomkp","email":"tom@tomkp.com"},"repository":{"url":"git+https://github.com/tomkp/react-split-pane.git","type":"git"},"_npmVersion":"11.0.0","description":"React split-pane component with hooks and TypeScript","directories":{},"sideEffects":false,"_nodeVersion":"24.6.0","_hasShrinkwrap":false,"devDependencies":{"vite":"^6.3.5","jsdom":"^26.1.0","react":"^18.3.1","tslib":"^2.8.1","eslint":"^9.39.2","rollup":"^4.54.0","vitest":"^4.0.16","globals":"^16.2.0","prettier":"^3.7.4","react-dom":"^18.3.1","typescript":"^5.8.3","@types/react":"^18.3.27","@types/react-dom":"^18.3.7","typescript-eslint":"^8.50.0","@vitest/coverage-v8":"^4.0.16","@testing-library/dom":"^10.4.0","@vitejs/plugin-react":"^4.7.0","@rollup/plugin-terser":"^0.4.4","@testing-library/react":"^16.3.1","@rollup/plugin-commonjs":"^29.0.0","@rollup/plugin-typescript":"^12.3.0","@testing-library/jest-dom":"^6.9.1","@rollup/plugin-node-resolve":"^16.0.3","@testing-library/user-event":"^14.5.2"},"peerDependencies":{"react":"^17.0.0 || ^18.0.0 || ^19.0.0","react-dom":"^17.0.0 || ^18.0.0 || ^19.0.0"},"_npmOperationalInternal":{"tmp":"tmp/react-split-pane_3.1.0_1771412613981_0.8573332313374655","host":"s3://npm-registry-packages-npm-production"},"readme":"# React Split Pane v3\n\nModern, accessible, TypeScript-first split pane component for React.\n\n[![NPM version](https://img.shields.io/npm/v/react-split-pane.svg?style=flat)](https://www.npmjs.com/package/react-split-pane)\n![NPM license](https://img.shields.io/npm/l/react-split-pane.svg?style=flat)\n[![NPM downloads](https://img.shields.io/npm/dm/react-split-pane.svg?style=flat)](https://www.npmjs.com/package/react-split-pane)\n[![Bundle size](https://img.shields.io/bundlephobia/minzip/react-split-pane)](https://bundlephobia.com/package/react-split-pane)\n\n**[Live Examples](https://tomkp.github.io/react-split-pane)**\n\n## ✨ Features\n\n- 🪝 **Hooks-based** - Built with modern React patterns\n- 📘 **TypeScript** - Full type safety out of the box\n- ♿ **Accessible** - Keyboard navigation, ARIA attributes, screen reader support\n- 📱 **Touch-friendly** - Full mobile/tablet support\n- 🎯 **Flexible** - Controlled/uncontrolled modes, nested layouts, 2+ panes\n- 🪶 **Lightweight** - < 5KB gzipped\n- ⚡ **Performant** - RAF-throttled resize, optimized renders\n- 🎨 **Customizable** - Full styling control\n\n## Installation\n\n```bash\nnpm install react-split-pane\n\n# or\nyarn add react-split-pane\n\n# or\npnpm add react-split-pane\n```\n\n## Quick Start\n\n```tsx\nimport { SplitPane, Pane } from 'react-split-pane';\n\nfunction App() {\n  return (\n    <SplitPane direction=\"horizontal\">\n      <Pane minSize=\"200px\" defaultSize=\"300px\">\n        <Sidebar />\n      </Pane>\n      <Pane>\n        <MainContent />\n      </Pane>\n    </SplitPane>\n  );\n}\n```\n\n> **Note:** SplitPane requires its container to have explicit dimensions. The component uses `width: 100%` and `height: 100%`, so the parent element must have a defined size. For vertical splits, ensure the parent has an explicit height (e.g., `height: 100vh`). See [Container Sizing](#container-sizing) for details.\n\n## Basic Usage\n\n### Horizontal Split (Side-by-Side)\n\n```tsx\n<SplitPane direction=\"horizontal\">\n  <Pane defaultSize=\"25%\">\n    <LeftPanel />\n  </Pane>\n  <Pane>\n    <RightPanel />\n  </Pane>\n</SplitPane>\n```\n\n### Vertical Split (Top-Bottom)\n\n```tsx\n<SplitPane direction=\"vertical\">\n  <Pane defaultSize=\"100px\">\n    <Header />\n  </Pane>\n  <Pane>\n    <Content />\n  </Pane>\n</SplitPane>\n```\n\n### Controlled Mode\n\n```tsx\nfunction App() {\n  const [sizes, setSizes] = useState([300, 500]);\n\n  return (\n    <SplitPane onResize={setSizes}>\n      <Pane size={sizes[0]} minSize=\"200px\">\n        <Sidebar />\n      </Pane>\n      <Pane size={sizes[1]}>\n        <Main />\n      </Pane>\n    </SplitPane>\n  );\n}\n```\n\n### Nested Layouts\n\n```tsx\n<SplitPane direction=\"vertical\">\n  <Pane defaultSize=\"60px\">\n    <Header />\n  </Pane>\n\n  <SplitPane direction=\"horizontal\">\n    <Pane defaultSize=\"250px\" minSize=\"150px\">\n      <Sidebar />\n    </Pane>\n\n    <SplitPane direction=\"vertical\">\n      <Pane>\n        <Editor />\n      </Pane>\n      <Pane defaultSize=\"200px\">\n        <Console />\n      </Pane>\n    </SplitPane>\n  </SplitPane>\n</SplitPane>\n```\n\n## Advanced Features\n\n### Persistence\n\nThe `usePersistence` hook saves and restores pane sizes to localStorage (or sessionStorage):\n\n```tsx\nimport { usePersistence } from 'react-split-pane/persistence';\n\nfunction App() {\n  const [sizes, setSizes] = usePersistence({ key: 'my-layout' });\n\n  return (\n    <SplitPane onResize={setSizes}>\n      <Pane size={sizes[0] || 300}>\n        <Sidebar />\n      </Pane>\n      <Pane size={sizes[1]}>\n        <Main />\n      </Pane>\n    </SplitPane>\n  );\n}\n```\n\n#### usePersistence Options\n\n| Option | Type | Default | Description |\n|--------|------|---------|-------------|\n| `key` | `string` | Required | Storage key for persisting sizes |\n| `storage` | `Storage` | `localStorage` | Storage backend (localStorage or sessionStorage) |\n| `debounce` | `number` | `300` | Debounce delay in ms before saving |\n\n```tsx\n// Use sessionStorage instead of localStorage\nconst [sizes, setSizes] = usePersistence({\n  key: 'my-layout',\n  storage: sessionStorage,\n  debounce: 500,\n});\n```\n\n### Snap Points\n\n```tsx\n<SplitPane\n  snapPoints={[200, 400, 600]}\n  snapTolerance={20}\n>\n  {/* panes */}\n</SplitPane>\n```\n\n### Custom Divider\n\n```tsx\nfunction CustomDivider(props) {\n  return (\n    <div {...props} style={{ ...props.style, background: 'blue' }}>\n      <GripIcon />\n    </div>\n  );\n}\n\n<SplitPane divider={CustomDivider}>\n  {/* panes */}\n</SplitPane>\n```\n\n## Keyboard Navigation\n\nThe divider is fully keyboard accessible:\n\n- **Arrow Keys**: Resize by `step` pixels (default: 10px)\n- **Shift + Arrow**: Resize by larger step (default: 50px)\n- **Home**: Minimize left/top pane\n- **End**: Maximize left/top pane\n- **Escape**: Restore pane sizes to initial state\n- **Tab**: Navigate between dividers\n\n## API Reference\n\n### SplitPane Props\n\n| Prop | Type | Default | Description |\n|------|------|---------|-------------|\n| `direction` | `'horizontal' \\| 'vertical'` | `'horizontal'` | Layout direction |\n| `resizable` | `boolean` | `true` | Whether panes can be resized |\n| `snapPoints` | `number[]` | `[]` | Snap points in pixels |\n| `snapTolerance` | `number` | `10` | Snap tolerance in pixels |\n| `step` | `number` | `10` | Keyboard resize step |\n| `onResizeStart` | `(event) => void` | - | Called when resize starts |\n| `onResize` | `(sizes, event) => void` | - | Called during resize |\n| `onResizeEnd` | `(sizes, event) => void` | - | Called when resize ends |\n| `className` | `string` | - | CSS class name |\n| `style` | `CSSProperties` | - | Inline styles |\n| `divider` | `ComponentType` | - | Custom divider component |\n| `dividerClassName` | `string` | - | Divider class name |\n| `dividerStyle` | `CSSProperties` | - | Divider inline styles |\n\n### Pane Props\n\n| Prop | Type | Default | Description |\n|------|------|---------|-------------|\n| `defaultSize` | `string \\| number` | `'50%'` | Initial size (uncontrolled) |\n| `size` | `string \\| number` | - | Controlled size |\n| `minSize` | `string \\| number` | `0` | Minimum size |\n| `maxSize` | `string \\| number` | `Infinity` | Maximum size |\n| `className` | `string` | - | CSS class name |\n| `style` | `CSSProperties` | - | Inline styles |\n\n## Container Sizing\n\nSplitPane uses `width: 100%` and `height: 100%` and measures its container via ResizeObserver. **The parent container must have explicit dimensions** for panes to render correctly.\n\n### Common Issue: Invisible Panes\n\nIf your pane content doesn't appear, the most common cause is a missing height on the parent container. This is especially true for vertical splits:\n\n```tsx\n// ❌ Won't work - parent has no height\nfunction App() {\n  return (\n    <div>\n      <SplitPane direction=\"vertical\">\n        <Pane><div>Top</div></Pane>\n        <Pane><div>Bottom</div></Pane>\n      </SplitPane>\n    </div>\n  );\n}\n\n// ✅ Works - parent has explicit height\nfunction App() {\n  return (\n    <div style={{ height: '100vh' }}>\n      <SplitPane direction=\"vertical\">\n        <Pane><div>Top</div></Pane>\n        <Pane><div>Bottom</div></Pane>\n      </SplitPane>\n    </div>\n  );\n}\n```\n\n### Solutions\n\n1. **Set explicit height on parent** (recommended for most cases):\n   ```css\n   .container { height: 100vh; }\n   ```\n\n2. **Use absolute positioning**:\n   ```css\n   .container { position: absolute; inset: 0; }\n   ```\n\n3. **Use flexbox with flex-grow**:\n   ```css\n   .parent { display: flex; flex-direction: column; height: 100vh; }\n   .container { flex: 1; }\n   ```\n\n## Styling\n\n### Default Stylesheet\n\nImport the optional default styles with CSS custom properties:\n\n```tsx\nimport 'react-split-pane/styles.css';\n```\n\nCustomize via CSS variables:\n\n```css\n.my-split-pane {\n  --split-pane-divider-size: 8px;\n  --split-pane-divider-color: #e0e0e0;\n  --split-pane-divider-color-hover: #b0b0b0;\n  --split-pane-focus-color: #2196f3;\n}\n```\n\nThe default styles include dark mode support via `prefers-color-scheme`.\n\n### Basic Styles\n\n```css\n.split-pane {\n  height: 100vh;\n}\n\n.split-pane-divider {\n  background: #e0e0e0;\n  transition: background 0.2s;\n}\n\n.split-pane-divider:hover {\n  background: #b0b0b0;\n}\n\n.split-pane-divider:focus {\n  outline: 2px solid #2196f3;\n  outline-offset: -2px;\n}\n```\n\n### Expanded Hover Area\n\nThis classic pattern creates a thin visible divider with a larger grabbable area that reveals on hover:\n\n```css\n.split-pane-divider {\n  background: #000;\n  opacity: 0.2;\n  z-index: 1;\n  box-sizing: border-box;\n  background-clip: padding-box;\n}\n\n.split-pane-divider:hover {\n  transition: all 0.2s ease;\n}\n\n.split-pane-divider.horizontal {\n  width: 11px;\n  margin: 0 -5px;\n  border-left: 5px solid rgba(255, 255, 255, 0);\n  border-right: 5px solid rgba(255, 255, 255, 0);\n  cursor: col-resize;\n}\n\n.split-pane-divider.horizontal:hover {\n  border-left: 5px solid rgba(0, 0, 0, 0.5);\n  border-right: 5px solid rgba(0, 0, 0, 0.5);\n}\n\n.split-pane-divider.vertical {\n  height: 11px;\n  margin: -5px 0;\n  border-top: 5px solid rgba(255, 255, 255, 0);\n  border-bottom: 5px solid rgba(255, 255, 255, 0);\n  cursor: row-resize;\n}\n\n.split-pane-divider.vertical:hover {\n  border-top: 5px solid rgba(0, 0, 0, 0.5);\n  border-bottom: 5px solid rgba(0, 0, 0, 0.5);\n}\n```\n\n### Minimal Divider\n\nA subtle single-pixel divider:\n\n```css\n.split-pane-divider.horizontal {\n  width: 1px;\n  margin: 0;\n  background: linear-gradient(to right, transparent, #ccc, transparent);\n}\n\n.split-pane-divider.vertical {\n  height: 1px;\n  margin: 0;\n  background: linear-gradient(to bottom, transparent, #ccc, transparent);\n}\n```\n\n## Tailwind CSS & shadcn/ui\n\nReact Split Pane works seamlessly with Tailwind CSS and shadcn/ui. See [TAILWIND.md](./TAILWIND.md) for detailed integration examples including custom dividers and CSS variable overrides.\n\n## Migration from v0.1.x or v2.x\n\nSee [MIGRATION.md](./MIGRATION.md) for detailed migration guide.\n\n**Quick changes:**\n\n```tsx\n// v0.1.x\n<SplitPane split=\"vertical\" minSize={50} defaultSize={100}>\n  <div>Pane 1</div>\n  <div>Pane 2</div>\n</SplitPane>\n\n// v3\n<SplitPane direction=\"horizontal\">\n  <Pane minSize=\"50px\" defaultSize=\"100px\">\n    <div>Pane 1</div>\n  </Pane>\n  <Pane>\n    <div>Pane 2</div>\n  </Pane>\n</SplitPane>\n```\n\n## Browser Support\n\n- Chrome/Edge (latest 2 versions)\n- Firefox (latest 2 versions)\n- Safari (latest 2 versions)\n- Mobile browsers (iOS Safari, Chrome Android)\n\n**Note:** IE11 is not supported. Use v0.1.x for IE11 compatibility.\n\n## Contributing\n\nContributions are welcome! Please see [CONTRIBUTING.md](./CONTRIBUTING.md).\n\n## License\n\nMIT © [tomkp](https://github.com/tomkp)\n","publish_time":1771412614149,"_cnpm_publish_time":1771412614149,"dist-tags":{"latest":"3.3.0"}}