Grid

A responsive grid that lays out child blocks in equal-width cells. The block uses Volto's standard shared-blocks shape — blocks is the dict of children, blocks_layout.items is their order — and constrains the allowed types via allowedBlocks.

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.

Design

We craft beautiful interfaces that users love.

Read more
Placeholder
Learn More

Explore the full documentation.

Read more

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: {
        id: 'gridBlock',
        // The chooser group, stated: a block's group is never made up.
        group: 'common',
        // Match Volto core's grid (allowedBlocks: ['image','listing','slate','teaser']).
        // gridBlock is used with slate cards and listings throughout the content
        // (e.g. docs/examples/grid/text, docs/examples/grid/listing, the homepage
        // "Why Hydra" cards); the old ['teaser','image'] wrongly rejected those, which
        // made the chevron move (and drop) walk children OUT of the grid to a parent
        // that accepts the type. Keep gridBlock (no nesting) and hero out of it.
        allowedBlocks: ['slate', 'image', 'listing', 'teaser'],
        blockSchema: {
            fieldsets: [{ id: 'default', title: 'Default', fields: ['items', 'variation', 'headline', 'headlineTag'] }],
            properties: {
                headline: { title: 'Headline', type: 'string' },
                headlineTag: { title: 'Headline tag', widget: 'select', choices: [['h1','h1'],['h2','h2'],['h3','h3'],['h4','h4'],['h5','h5'],['h6','h6']] },
                items: {
                    widget: 'blocks_layout',
                    itemTypeField: 'variation',  // sync trigger
                    allowedBlocks: ['slate', 'image', 'listing', 'teaser'],
                },
                variation: {
                    title: 'Item Type',
                    widget: 'blockTypeSelect',
                },
            },
        },
        schemaEnhancer: {
            inheritSchemaFrom: {
                defaultsField: 'itemDefaults',
                // Same override as listing — keep teaser's `overwrite` toggle
                // editable per-child even when grid has a type selected.
                parentControlled: {
                    teaser: ['head_title', 'openLinkInNewTab', 'styles'],
                },
            },
        },
    }

JSON Block Data

Example block JSON (as stored in the CMS). This is the data structure your component will receive in the block prop.

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

Rendering

How this block renders in your frontend. Add its handling to your renderer, or — for list-style blocks — register a fetcher and reuse your list rendering.

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>
  );
}