Skip to content

Build post blocks

Style the default post blocks with your brand, and add custom blocks for your editors.

Not built yet — This describes where the product is going, not what you can use today. It's documented so the direction is legible — nothing here works yet.

Posts are made of blocks: paragraphs, headings, images, callouts, and so on. Editors pick them in the block editor, and your post page renders them. The Deco Blog app ships a default set, but its styling is generic. To make posts look like your brand, build your own blocks in your site.

Post blocks live in sections/Blog/Post/ (src/sections/Blog/Post/ on TanStack sites). The Site Editor offers every block in that folder when someone writes a post. They are listed first in the picker, under Custom blocks when the app's blocks are shown too. There are two kinds:

  • Default blocks, which reuse the name and props of an app block, such as Paragraph. They get the same editor as the app's block, with your styling.
  • Custom blocks, with any other name. They get a form built from their props.

Restyle a default block

Create a file with the same name as the app's block and the same props, and add your own markup and styles. The Site Editor recognizes the block by its file name and opens its usual editor — rich text for a paragraph, level and text for a heading — while your component renders it on the site.

For example, src/sections/Blog/Post/Paragraph.tsx:

import type { Props } from "@decocms/apps-blog/sections/blocks/Paragraph";
 
export type { Props };
 
export default function Paragraph({ html, text }: Props) {
  return (
    <p
      className="font-serif text-lg leading-relaxed text-brand-ink mb-6 [&_a]:text-brand-accent [&_a]:underline"
      dangerouslySetInnerHTML={{ __html: html ?? text ?? "" }}
    />
  );
}

Importing the Props type from the app keeps your block's props identical to the app's. On Deno sites, import it from apps/blog/sections/blocks/Paragraph.tsx.

These are the names and props the editors expect:

Block (file name)Shown in the picker asProps
ParagraphParagraphhtml
HeadingHeadingtext, level
ListListitems, style
BlockImageImageurl, mobileUrl, alt, caption, size, highPriority
VideoVideourl, caption
QuoteQuotequote
CalloutCallouttitle, body, variant
CodeCodecode, language
TableTableheaders, rows
ChecklistChecklisttitle, items
StepsStepstitle, steps
ComparisonComparisonleft, right
CardGroupCard groupcards
Stat, StatGroupStat, Stat groupvalue, label, description; stats
CtaCall to actiontext, href
DividerDivider—
ProductCard, ProductShelfProduct card, Product shelfCommerce sites only. Products chosen in the editor.

A block with one of these names but different props won't load correctly in its editor.

To offer only your own blocks, an organization manager can turn on Hide the default blog blocks in the organization's general settings, under Blog blocks. Blocks already used in posts keep rendering.

Add a custom block

Any other file in sections/Blog/Post/ becomes a custom block. Its props define the form editors fill in:

Form of a custom block: a required text field (1), an image with alt text (2), a list of items (3), and an optional ID (4)

import type { ImageWidget } from "@decocms/blocks/types/widgets";
 
/** @title Highlight */
export interface Props {
  /** @title Text */
  text: string;
  /** @title Image */
  image?: {
    /** @title Image */
    src: ImageWidget;
    /** @title Alt text */
    alt: string;
  };
  /** @title Items */
  items?: { label: string; description?: string }[];
}
  • @title sets the label, and @description adds help text below it. On the block itself, they set its name and description in the picker. @icon sets its icon.
  • Props without ? are required and show a marker until they're filled in (1).
  • ImageWidget gives an image upload (2). The same module also has VideoWidget, RichText, TextArea, and Color.
  • Arrays become lists with Add item (3), and nested objects become groups.

Render the blocks on the post page

The post page's section decides which component renders each block. In the template, src/sdk/blog/blocks.tsx maps each block name to a component: DEFAULT_BLOCKS for the app's blocks and CUSTOM_BLOCKS for the ones in sections/Blog/Post/. When you add a block, register it in CUSTOM_BLOCKS; a block missing from the map doesn't render.

The template's post section also passes an id to headings and custom blocks for its table of contents. Add an optional id prop to blocks that should be linkable.

Implementation reference: blog-tanstack post blocks. Reviewed 2026-10-09.