Grid

Grid-image block

The Grid block allows adding multi-column blocks. A grid block can contain between one and four columns of different blocks. Text, teasers, images and videos can be added in a grid block.

Grid-Listing

The Grid block allows adding multi-column blocks. A grid block can contain between one and four columns of different blocks. This is a grid block with multiple listing blocks.

Grid-Teaser block

The Grid block allows adding multi-column blocks. A grid block can contain between one and four columns of different blocks. Text, teasers, images and videos can be added in a grid block.

Grid-Text block

The Grid block allows adding multi-column blocks. A grid block can contain between one and four columns of different blocks. Text, teasers, images and videos can be added in a grid block.


Developer Reference

Schema

Pass this object inside the blocks option when calling initBridge() to register this block type with the admin UI. See Custom Blocks for the full setup guide.

{
  "gridBlock": {
    "allowedBlocks": ["teaser", "image", "slate"],
    "blockSchema": {
      "properties": {
        "blocks_layout": {
          "title": "Cells",
          "widget": "blocks_layout",
          "allowedBlocks": ["teaser", "image", "slate"]
        }
      }
    }
  }
}

JSON Block Data

Example JSON as stored in the Plone content API. This is the data structure your component will receive in the block prop.

{
  "@type": "gridBlock",
  "blocks": {
    "cell-1": {
      "@type": "teaser",
      "title": "Design",
      "description": "We craft beautiful interfaces that users love.",
      "href": [{"@id": "/design"}]
    },
    "cell-2": {
      "@type": "image",
      "url": "https://placehold.co/600x400",
      "alt": "Placeholder"
    },
    "cell-3": {
      "@type": "teaser",
      "title": "Learn More",
      "description": "Explore the full documentation.",
      "href": [{"@id": "/docs"}]
    }
  },
  "blocks_layout": {
    "items": ["cell-1", "cell-2", "cell-3"]
  }
}

Component

Render component for your frontend framework. Add this to your block renderer's switch/map so it handles this @type.

function GridBlock({ block }) {
  const blocks = block.blocks || {};
  const items = block.blocks_layout?.items || [];

  return (
    <div data-block-uid={block['@uid']} className="grid-block">
      <div style={{ display: 'grid', gridTemplateColumns: `repeat(${items.length}, 1fr)`, gap: '1rem' }}>
        {items.map(id => {
          const child = { ...blocks[id], '@uid': id };
          return (
            <div key={id} className="grid-cell">
              <BlockRenderer block={child} />
            </div>
          );
        })}
      </div>
    </div>
  );
}