Block Based
GitHub

Getting Started

block-based is a composable, block-based UI builder component for React. It lets you design block layouts visually and export them as HTML with a single function call.

Installation

npm install block-based

Peer dependencies — make sure these are already in your project:

npm install react react-dom lucide-react

Quick Start

import { EmailBlockEditor, renderEmailDocument, createEmptyDocument } from 'block-based';
import { useState } from 'react';

export function App() {
  const [doc, setDoc] = useState(createEmptyDocument);

  return (
    <div>
      <EmailBlockEditor value={doc} onChange={setDoc} height="600px" />
      <button onClick={() => {
        const html = renderEmailDocument(doc);
        console.log(html);
      }}>
        Export HTML
      </button>
    </div>
  );
}

That's it — you have a fully functional block builder. The doc state is a plain JSON object that you can persist to any database, and renderEmailDocument() converts it to clean, production-ready HTML.

What's Included

FeatureDescription
8 block typesHeading, Paragraph, Button, Image, Divider, Spacer, Menu, HTML
Multi-column layouts1–4 column sections with flexible width ratios
Drag & dropReorder blocks and sections via dnd-kit
Visual inspectorEdit typography, colors, padding, margins, borders
Responsive previewDesktop, tablet, and mobile view modes
HTML exportClean, production-ready HTML output
Color paletteSemantic color system with custom color support
TemplatesPre-built section templates (hero, CTA, two-column)

Next Steps