npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

block-based

v0.1.1

Published

A composable, block-based UI builder component for React

Downloads

483

Readme

block-based

A composable, block-based email builder component for React. Drag-and-drop blocks, multi-column layouts, live preview, and HTML rendering — all in a single dependency.

npm version license

Documentation · Live Demo

Features

  • 8 block types — Heading, Paragraph, Button, Image, Divider, Spacer, Menu, HTML
  • Multi-column layouts — 1 to 4 columns with adjustable widths
  • Drag-and-drop — Reorder blocks and rows via @dnd-kit
  • Live preview — Desktop, tablet, and mobile viewports
  • HTML rendering — Generate email-compatible HTML from the document model
  • Color palette — Semantic token system (shadcn UI conventions) with custom color support
  • Light/dark themetheme="light" or theme="dark" for the editor UI
  • Customizable — Feature flags, custom sidebar tabs, sample blocks, templates
  • Zero CSS — All styles are inline; no external stylesheets needed
  • TypeScript — Fully typed API with exported types

Installation

npm install block-based
# or
pnpm add block-based
# or
yarn add block-based

Peer dependencies

block-based requires the following peer dependencies:

npm install react react-dom lucide-react

Quick start

import { useState } from "react";
import { EmailBlockEditor, createEmptyDocument } from "block-based";
import type { EmailDocument } from "block-based";

function App() {
  const [doc, setDoc] = useState<EmailDocument>(createEmptyDocument);

  return (
    <EmailBlockEditor
      value={doc}
      onChange={setDoc}
      height="100vh"
    />
  );
}

Rendering to HTML

import { renderEmailDocument } from "block-based";

const html = renderEmailDocument(doc);
// → Full email-compatible HTML string

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | value | EmailDocument | — | Controlled document state | | onChange | (doc: EmailDocument) => void | — | Called on every edit | | height | string \| number | '100%' | Editor container height | | theme | 'light' \| 'dark' | 'light' | Editor UI color scheme | | defaultPalette | Partial<ColorPalette> | — | Override default color palette tokens | | sampleBlocks | SampleBlock[] | — | Extra blocks in the Content tab | | templates | TemplateDefinition[] | — | Extra templates in the Templates tab | | customTabs | CustomTab[] | — | Custom sidebar tabs | | features | Partial<EditorFeatures> | all true | Enable/disable editor capabilities |

Feature flags

Toggle individual editor capabilities via the features prop:

<EmailBlockEditor
  features={{
    content: true,      // Content palette tab
    rows: true,         // Rows/layouts palette tab
    templates: true,    // Prebuilt section templates tab
    treeView: true,     // Document tree view tab
    json: false,        // Hide the built-in JSON tab
    html: false,        // Hide the built-in HTML tab
    bodySettings: true, // Body settings panel
    preview: true,      // Preview mode toggle
    dragDrop: true,     // Drag-and-drop reordering
    customColors: true, // Custom color management
  }}
/>

Block types

| Type | Description | |------|-------------| | heading | Heading text with configurable size, weight, color, alignment | | paragraph | Body text with font size, color, alignment | | button | CTA button with URL, colors, border radius, width modes | | image | Image with URL, alt text, width, alignment | | divider | Horizontal rule with color and thickness | | spacer | Empty space with configurable height | | menu | Navigation links with spacing and alignment | | html | Raw HTML block for custom content |

Document model

type EmailDocument = {
  version: 1;
  settings: EmailDocumentSettings; // colors, fonts, layout
  sections: EmailSection[];        // rows of content
};

type EmailSection = {
  id: string;
  columns: EmailColumn[];        // 1–4 columns per row
  backgroundColor?: string;
  // padding, margin, border, opacity, borderRadius...
};

type EmailColumn = {
  id: string;
  width: number;                 // percentage width (e.g. 50)
  blocks: EmailBlock[];          // content blocks
};

Development

This is a Turborepo monorepo using pnpm.

pnpm install
pnpm dev

Structure

packages/
  block-builder/     # Core library (published as `block-based`)
apps/
  landing/           # Documentation site & live example

License

MIT