# react-layout-builder

> Build form layout

Latest version **2.1.0** (published 2018-05-19) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2018-05-19 |
| First published | 2016-10-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 4.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | code@alvinsj.net |
| Maintainers | alvinsj |
| Keywords | reactjs, form, layout, builder, react-component |

## Links

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

## Dependencies (2)

- [object-assign](https://npm.io/package/object-assign.md) ^4.x.x
- [react-form-utils](https://npm.io/package/react-form-utils.md) ^2.0.0

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

- 2.1.0 (latest) — 2018-05-19
- 2.0.0 — 2018-05-18
- 1.2.0 — 2018-05-18
- 2.0.0-beta.1 — 2017-11-07
- 2.0.0-alpha.9 — 2017-10-17
- 2.0.0-alpha.8 — 2017-10-17
- 2.0.0-alpha.7 — 2017-10-17
- 2.0.0-alpha.6 — 2017-10-12
- 2.0.0-alpha.5 — 2017-10-12
- 2.0.0-alpha.4 — 2017-10-12
- 2.0.0-alpha.3 — 2017-09-20
- 2.0.0-alpha.1 — 2017-09-20
- 1.1.7 — 2017-08-17
- 1.0.15 — 2017-08-17
- 1.0.13 — 2017-08-17
- … 8 more at https://npm.io/package/react-layout-builder/versions

## README

## react-layout-builder

[![Build Status](https://travis-ci.org/blacktangent/react-layout-builder.svg?branch=master)](https://travis-ci.org/blacktangent/react-layout-builder)

`react-layout-builder` provides helper functions to build layout like a DSL.

```
$ yarn add react-layout-builder
```

```
import {layout, section, col} from 'react-layout-builder';
```

### Example

```jsx
import React from 'react';
import {
  layout,
  section,
  col
} from 'react-layout-builder';

const PhotoAlbum = props => {
  const { images } = props;
  const three60s = images.filter(i => i.type == '360');

  const renderImage = (name) => {
    const image = images.find(i => i.name === name);
    return <img alt={image.title} src={image.url} />;
  }
  const grid = (className, ...images) =>
    col(renderImage, className, ...images.map(i => i.name));

  return layout(
    section('Photos',
        new Array( Math.ceil( images.length/3 ) )
        .map( _ =>
          grid(
            'grid-of-3',
            images.pop(),
            images.pop(),
            images.pop()
          )
        )
    ),
    section('360 Photos',
        three60s
        .map( p => grid('full-width', p) )
    ),
  <p key="copyright">Copyrighted by author</p>
  );

}
```

### Usage

#### `layout`
```jsx
/*
 * @param {node} mainHeader
 * @param {node} section
 * @return {node}
 */
layout(mainHeader, ...sections)
// <div className="layout">{sections}</div>
```
#### `section`
```jsx
/*
 * @param {node} sectionHeader
 * @param {node} row
 * @return {node}
 */
section(sectionHeader, ...rows)
// <section className="section">{rows}</section>
```

#### `col`
```jsx
/*
 * @param {string} className - the group identifier for all columns within.
 * @param {string} fieldName - the name for lookup with `getFieldProps`+`renderField`
 * @return {node}
 */
col(renderField, className, ...names)
// <div className={className}>
//  {names.map(name => renderField(name))}
// </className>

```

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