A grid your client arranges by hand. They drag each box to where it goes and how big it is, and put any blocks inside: your own styled blocks as well as WordPress's. It does the job of columns without the columns, and makes a bento layout something a client can rearrange.
Download example A zip of block folders for your theme. Needs GCB 1.3.1 or later, and nothing else.
What's in the download
layout/The grid. Alayoutfield stores where every box sits, for desktop and for phones.layout-box/One box. Any blocks inside, with an optional background picture, video or colour.
Each folder is an ordinary GCB block: block.json, block.fields.json and render.php, plus a style.css and a view.js where it needs them. There is no build step and no library.
How it's built
The grid is one field of the layout type. The editor draws it as a board your client drags boxes on, and the template turns the stored positions into CSS grid placement. The boxes themselves are child blocks, marked with a <Repeater>.
<Repeater allowedBlocks='["gcb/layout-box"]' addButtonLabel="Add box" min="1" max="48" editLayout="grid"/>Its fields, from block.fields.json:
| Field | Type |
|---|---|
| Layout | layout |
| Gap | range |
There is no script: the page is CSS grid.
Use it
- Unzip the download.
- Copy
layout/andlayout-box/into your theme'sblocks/folder. - Reload the block editor. The block is in the inserter.
That's all of it. You don't register the block: there's no register_block_type() call and nothing to add to functions.php. GCB registers every folder in your theme's blocks/ folder by itself.
It is your block now. Change the markup, the fields or the script to suit the design. The docs cover every field type and marker used here.
More examples: all examples, or download them together as the GCB Kit.