Block Based
GitHub

Sections & Layouts

Sections are horizontal rows in the document. Each section contains one or more columns, and each column contains an array of blocks.

Layout Presets

The editor's Rows sidebar tab provides built-in layout presets:

PresetColumnsWidth Ratios
1 column1100%
2 columns250% / 50%
3 columns333.33% each
4 columns425% each
Sidebar left235% / 65%
Sidebar right265% / 35%

Creating Sections Programmatically

Use createSectionTemplate() to generate pre-built sections:

import { createSectionTemplate } from 'block-based';

// Hero section with heading + paragraph + button
const hero = createSectionTemplate('hero');

// Empty single column
const blank = createSectionTemplate('blank');

// Two equal columns with placeholder content
const twoCols = createSectionTemplate('two-column');

// Call-to-action section with colored background
const cta = createSectionTemplate('cta');

Appending Sections to a Document

import { appendGeneratedSections } from 'block-based';

const updatedDoc = appendGeneratedSections(doc, [
  createSectionTemplate('hero'),
  createSectionTemplate('two-column'),
]);

Custom Section Input

For full control, use normalizeSection() with a partial input:

import { normalizeSection, createBlock } from 'block-based';

const section = normalizeSection({
  columns: [
    {
      width: '60%',
      blocks: [createBlock('heading'), createBlock('paragraph')],
    },
    {
      width: '40%',
      blocks: [createBlock('image')],
    },
  ],
  backgroundColor: '#f0f9ff',
  paddingTop: 32,
  paddingBottom: 32,
});

The normalizer fills in missing IDs and default values automatically.

Section Properties

Each section supports: