Skip to main content

Allotment

Resizable split panes for React, derived from VS Code

This is Allotment. Drag the edges, double-click them to reset, and use the buttons in the title bar to show and hide panes.

$ npm install allotment
npm versionnpm downloads per weekBundle sizeTypes includedLicense

Up and running in a minute

  1. Install allotment. It works with React 17, 18 and 19.
  2. Import the component and its stylesheet, allotment/dist/style.css.
  3. Put your panes inside Allotment, in a parent with a height.
Read the getting started guide →
import { Allotment } from "allotment";
import "allotment/dist/style.css";

export const App = () => (
<div style={{ height: 400 }}>
<Allotment>
<Sidebar />
<Editor />
</Allotment>
</div>
);

Props at a glance

Allotment

PropDefaultDescription
vertical
boolean
falseStack panes vertically instead of horizontally.
defaultSizes
number[]
Initial sizes of the panes, scaled to fit.
minSize
number
30Minimum size of any pane.
maxSize
number
InfinityMaximum size of any pane.
snap
boolean
falseLet every pane snap closed.
onChange
(sizes: number[]) => void
Called when the pane sizes change.
Full Allotment reference →

Allotment.Pane

PropDefaultDescription
minSize
number
Minimum size of this pane.
maxSize
number
Maximum size of this pane.
preferredSize
number | string
Size on mount and reset, e.g. 120 or "50%".
snap
boolean
falseLet this pane snap closed.
visible
boolean
trueWhether this pane is shown.
priority
LayoutPriority
NormalWhich panes resize first when the layout changes.
Full Allotment.Pane reference →

Derived from VS Code

Built on the same split view code as VS Code, so dragging, snapping and double-click to reset feel the way people expect.

Declarative

Add, remove and hide panes by changing your React children. Allotment works out the new sizes.

Closable panes →

Size constraints

Set minimum, maximum and preferred sizes per pane, fix a pane's size, or let it snap closed.

Sizing →

Nested layouts

Put one Allotment inside another to build editor-style layouts with sidebars and panels.

Nested →

TypeScript

Written in TypeScript and ships its own types, including the ref handle for resizing from code.

API reference →

Easy to style

Change colours and sash sizes with CSS variables, or target the component's class names.

Styling →