# react-draggable-layout

> a draggable React.js layout

Latest version **1.0.18** (published 2024-01-08) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.18 |
| Published | 2024-01-08 |
| First published | 2023-11-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 461 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Dariusz Socha |
| Maintainers | pierrickl, danielszlaski, bullapp.cloud |
| Keywords | react, reactjs, layout, columns, drag and drop, draggable, component |

## Links

- npm: https://www.npmjs.com/package/react-draggable-layout
- Repository: https://github.com/dsocha/react-draggable-layout
- Homepage: https://github.com/dsocha/react-draggable-layout#readme
- Issues: https://github.com/dsocha/react-draggable-layout/issues
- npm.io page: https://npm.io/package/react-draggable-layout

## Dependencies (3)

- [react](https://npm.io/package/react.md) ^18.2.0
- [react-dom](https://npm.io/package/react-dom.md) ^18.2.0
- [styled-components](https://npm.io/package/styled-components.md) ^5.3.11

## 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

- 1.0.18 (latest) — 2024-01-08
- 1.0.17 — 2024-01-08
- 1.0.16 — 2023-12-15
- 1.0.15 — 2023-12-13
- 1.0.14 — 2023-12-12
- 1.0.13 — 2023-12-12
- 1.0.12 — 2023-11-24
- 1.0.11 — 2023-11-24
- 1.0.10 — 2023-11-24
- 1.0.9 — 2023-11-24
- 1.0.8 — 2023-11-24
- 1.0.6 — 2023-11-24
- 1.0.5 — 2023-11-24
- 1.0.4 — 2023-11-24
- 1.0.3 — 2023-11-24
- … 3 more at https://npm.io/package/react-draggable-layout/versions

## README

# react-draggable-layout

Put your React.js components into a draggable column layout.

![alt text](screenshot.png)

## Pages

- [npm](https://www.npmjs.com/package/react-draggable-layout)
- [github](https://github.com/dsocha/react-draggable-layout)
- [sandbox](https://codesandbox.io/p/sandbox/react-draggable-layout-2rn4zr)

## Install

```bash
yarn add react-draggable-layout
```

```bash
npm install --save react-draggable-layout
```

## Usage

```jsx
import DraggableLayout from 'react-draggable-layout';

export default function App() {
  const components = [
    { col: 0, id: 'Component 1', component: <div style={{ height: '120px', backgroundColor: 'rgb(125 211 252)', borderRadius: '1rem', padding: '24px', boxShadow: '0 8px 10px -4px #cccccc' }}>Component #1</div> },
    { col: 0, id: 'Component 2', component: <div style={{ height: '180px', backgroundColor: 'rgb(153 246 228)', borderRadius: '1rem', padding: '24px', boxShadow: '0 8px 10px -4px #cccccc' }}>Component #2</div> },
    { col: 1, id: 'Component 3', component: <div style={{ height: '300px', backgroundColor: 'rgb(254 202 202)', borderRadius: '1rem', padding: '24px', boxShadow: '0 8px 10px -4px #cccccc' }}>Component #3</div> },
    { col: 1, id: 'Component 4', component: <div style={{ height: '250px', backgroundColor: 'rgb(191 219 254)', borderRadius: '1rem', padding: '24px', boxShadow: '0 8px 10px -4px #cccccc' }}>Component #4</div> },
    { col: 2, id: 'Component 5', component: <div style={{ height: '180px', backgroundColor: 'rgb(254 215 170)', borderRadius: '1rem', padding: '24px', boxShadow: '0 8px 10px -4px #cccccc' }}>Component #5</div> },
  ];

  const handleOnChange = (c) => {
    console.log('onChange()', c);
  };

  return (
    <div style={{ height: '100vh', backgroundColor: '#f4f4f4' }}>
      <DraggableLayout components={components} columns={3} mainColumnIndex={1} onChange={handleOnChange} draggable={true} />
    </div>
  );
}
```

## Properties

- **components**
  - An array of components that you want to place into DraggableLayout. Each object must contain following props:
    - **id** - a unique id
    - **col** - an index of column where you want to place your component
    - **component** - a component you want to place
- **onChange**
  - An event that is fired when a user draggs the component to another place.
- **columns**
  - Number of columns in the layout.
- **mainColumnIndex**
  - Index of the main column. The main column is wider than others.
- **draggable**
  - Set false if you want to disable drag and drop.

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