# react-resizable-layout

> Lightweight, accessible headless React component and hook for drag-and-drop resizable layouts.

Latest version **0.7.3** (published 2025-09-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-resizable-layout
pnpm add react-resizable-layout
yarn add react-resizable-layout
bun add react-resizable-layout
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.7.3 |
| Published | 2025-09-19 |
| First published | 2022-04-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 26 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 111 |
| Author | RyoSogawa |
| Maintainers | ryo-sogawa |
| Keywords | react, react-hooks, react-component, headless, dnd, resize, typescript |

## Links

- npm: https://www.npmjs.com/package/react-resizable-layout
- Repository: https://github.com/RyoSogawa/react-resizable-layout
- Issues: https://github.com/RyoSogawa/react-resizable-layout/issues
- npm.io page: https://npm.io/package/react-resizable-layout

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.7.3 (latest) — 2025-09-19
- 0.7.2 — 2023-10-21
- 0.7.1 — 2023-09-20
- 0.7.0 — 2023-09-01
- 0.6.0 — 2023-04-10
- 0.5.1 — 2023-03-16
- 0.5.0 — 2023-01-13
- 0.4.0 — 2022-10-27
- 0.3.1 — 2022-06-12
- 0.3.0 — 2022-06-12
- 0.2.4 — 2022-04-30
- 0.2.3 — 2022-04-30
- 0.2.2 — 2022-04-30
- 0.2.1 — 2022-04-30
- 0.1.9 — 2022-04-02
- … 9 more at https://npm.io/package/react-resizable-layout/versions

## README

# react-resizable-layout

[![npm version](https://badge.fury.io/js/react-resizable-layout.svg)](http://badge.fury.io/js/react-resizable-layout)
[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE)
[![minziggped size](https://badgen.net/bundlephobia/minzip/react-resizable-layout)](https://bundlephobia.com/package/react-resizable-layout)
[![dependencies count](https://badgen.net/bundlephobia/dependency-count/react-resizable-layout)](https://bundlephobia.com/package/react-resizable-layout)
[![tree shaking](https://badgen.net/bundlephobia/tree-shaking/react-resizable-layout)](https://bundlephobia.com/package/react-resizable-layout)

A lightweight, accessible headless React component and hook for drag-and-drop resizable layouts.

![Hero Image](./hero.gif)

[![Edit react-resizable-layout](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/react-resizable-layout-jy3vhk?fontsize=14&hidenavigation=1&theme=dark)

[Storybook Demo](https://react-resizable-layout.vercel.app/)

## Features

- 📦 Lightweight
- 🕳 Headless
- 🫶🏽 Accessible 
- 🤏 Drag and Drop Support
- ⌨️ Keyboard Support
- 🫙 Zero Dependencies
  

## Installation

Install from npm:

```
# Using npm
npm install react-resizable-layout

# Using Yarn
yarn add react-resizable-layout

# Using pnpm
pnpm add react-resizable-layout
```
  

## Usage
### `Resizable` component

```tsx
import Resizable from 'react-resizable-layout';

<Resizable axis={'x'}>
  {({ position, separatorProps }) => (
    <div className="wrapper">
      <div className="left-block" style={{ width: position }} />
      <YourSeparatorComponent {...separatorProps} />
      <div className="right-block" />
    </div>
  )}
</Resizable>
```

### `useResizable` hook

```tsx
import { useResizable } from 'react-resizable-layout';

const Component = () => {
  const { position, separatorProps } = useResizable({
    axis: 'x',
  })

  return (
    <div className="wrapper">
      <div className="left-block" style={{ width: position }} />
      <YourSeparatorComponent {...separatorProps} />
      <div className="right-block" />
    </div>
  )
}
```
  

## Aria Props
The following attributes are added to `separatorProps` in accordance with W3C.  
https://www.w3.org/TR/wai-aria-1.2/#separator

| Attribute        | Value                          |
|------------------|--------------------------------|
| role             | `'separator'`                  |
| aria-valuenow    | `position`                     |
| aria-valuemin    | `props.min`                    |
| aria-valuemax    | `props.max`                    |
| aria-orientation | `'vertical'` or `'horizontal'` |
| aria-disabled    | `props.disabled`               |
  

## Configuration

### Common Props

| Name          | Type                    | Default  | Required | Description                                                               |
|---------------|-------------------------|----------|----------|---------------------------------------------------------------------------|
| axis          | 'x' or 'y'              | -        | ◯        | Resize direction                                                          |
| containerRef  | ReactRef<HTMLElement>   | -        | -        | Reference to container for calculating position                           |
| disabled      | boolean                 | false    | -        | Disable resize                                                            |
| initial       | number                  | 0        | -        | Initial size                                                              |
| min           | number                  | 0        | -        | Minimum size                                                              |
| max           | number                  | Infinity | -        | Maximum size                                                              |
| reverse       | boolean                 | false    | -        | If true, returns position of the opposite side                            |
| step          | number                  | 10       | -        | Pixel steps when operating with keyboard                                  |
| shiftStep     | number                  | 50       | -        | Pixel steps when operating with keyboard while holding down the shift key |
| onResizeStart | function                | -        | -        | Callback on resize start                                                  |
| onResizeEnd   | function                | -        | -        | Callback on resize end                                                    |

### `Resizable` component children args

`useResizable` hook returns same.

| Name           | Type     | Description                                                    |
|----------------|----------|----------------------------------------------------------------|
| position       | number   | Separator's position (Width for 'x' axis, height for 'y' axis) |
| endPosition    | number   | Separator's position at end of drag                            |
| isDragging     | boolean  | True if dragging                                               |
| separatorProps | object   | Separator's props like onPointerDown                           |
| setPosition    | function | Set separator's position                                       |
  

## About keyboard support
The following keyboard operations are supported.

| Key                               | Operation                                   |
|-----------------------------------|---------------------------------------------|
| Arrow (`↑`,`→`,`↓`,`←`)           | Move the separator by 10px (default)        |
| `Shift` + Arrow (`↑`,`→`,`↓`,`←`) | Move the separator by 50px (default)        |
| `Enter`                           | Reset the separator to the initial position |
  

## About mouse support
Double-click on the separator to return it to its initial position.
  

## Contribution
Feel free to open an issue or make a pull request.
  

## License
Distributed under the MIT License. See [LICENSE](./LICENSE) for more information.

---
_Source: https://npm.io/package/react-resizable-layout · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
