Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
A

allotment

> 前端框架
Open source

A React component for resizable split views

1.3K stars0 likes2 views
WebsiteGitHub

About

A React component for resizable split views

Allotment

React split-pane component.
  • React-based: Integrate effortlessly into your existing React-based application.
  • Industry standard look and feel: Like VS Code's split view implementation? You're in luck! This component is derived from the same codebase.
  • Dynamic: Want to declaratively add and remove panes? We've got you covered.

Examples

You can find examples of using the library here.

Getting Started

Allotment is available from npm.

Prerequisites

Allotment has react and react-dom as peer dependencies.

bash
npm install react react-dom

Installation

bash
npm install allotment

Usage

javascript
import React from "react";
import { Allotment } from "allotment";
import "allotment/dist/style.css";

export const App = () => (
  
    
    
  
);

If you want more control over the behaviour of the individual panes you can use the Allotment.Pane component. This includes setting the minimum and maximum size of a pane, as well as whether to enable snapping behaviour.

javascript

  
    
  
  
    
  

Allotment props

All properties are optional.

defaultSizes

An array of initial sizes of the panes. If the sum of the sizes differs from the size of the container then the panes' sizes will be scaled proportionally.

javascript

  

);

Frequently asked questions

It's not working/I don't see anything

The Allotment component takes its width and height from the element which contains it. It does not come with an explicit width or height out of the box. It's easy to end up with a div of height zero by accident. For example, adding allotment to a brand new Create React App project without setting a height on a containing div won't work because the default root div itself has no height.

You should also check that the css has been imported/included, for example at the root of your application:

javascript
import "allotment/dist/style.css";

My content is larger than the containing pane. How can I let the user scroll?

The simplest approach is to place your content inside a new div with width and height 100% and overflow auto. This div will have the same dimensions as the pane it's inside and if its content overflows the browser will provide scrolling behaviour.

Next.js

If you get an error when importing allotment in a Next.js project consider not including the module server-side. Allotment currently only works in a browser. It might be possible to produce sensible results server-side in the future so create an issue requesting this if interested.

How do I prevent a pane from being resized?

Set minSize and maxSize props to the same value.

How do I style the component?

Some common style changes can be made by setting CSS variables.

These include:

Name Default Description
--focus-border #007fd4 Color of the sash when hovered
--separator-border rgba(128, 128, 128, 0.35) Color of the separator

For more involved styling you can target the component's child elements.

Class Description
.split-view Styles applied to the top-level container
.split-view-horizontal Styles applied to the top-level container if vertical={false}
.split-view-vertical Styles applied to the top-level container if vertical={true}
.split-view-separator-border Styles applied to the top-level container if separator={true}
.split-view-sash-dragging Styles applied to the top-level container if sash is dragging
.sash-container Styles applied to the sash container
.sash Styles applied to the sash
.sash-active Styles applied to the sash if being dragged
.sash-disabled Styles applied to the sash if disabled
.sash-horizontal Styles applied to the sash if vertical={false}
.sash-hover Styles applied to the sash if being hovered over
.sash-mac Styles applied to the sash if running under macos
.sash-maximum Styles applied to the sash if the pane is maximised
.sash-minimum Styles applied to the sash if the pane is minimised
.sash-vertical Styles applied to the sash if vertical={true}
.split-view-container Styles applied to the split view container
.split-view-view Styles applied to the split view view
.split-view-view-visible Styles applied to the split view view if visible={true}

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

TypeScriptpanepanelreactsplit

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category前端框架
PricingOpen source

> Related tools

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架