block-types > Introduction to Block Type Guide

Introduction to Block Type Guide

Notionpresso supports various block types from Notion, providing components that closely resemble Notion's style for each block type. This guide explains the currently supported block types, the Props for each block type, customization methods, and internal working principles.

Supported Block Types

Here's a list of block types currently supported and planned for support in Notionpresso:

Block TypeSupport StatusBlock Type Enum
Paragraph✅ Yesparagraph
Heading 1✅ Yesheading_1
Heading 2✅ Yesheading_2
Heading 3✅ Yesheading_3
Bulleted List Item✅ Yesbulleted_list_item
Numbered List Item✅ Yesnumbered_list_item
To-do❌ Noto_do
Toggle✅ Yestoggle
Quote✅ Yesquote
Callout✅ Yescallout
Equation❌ Noequation
Code❌ Nocode
Image❌ Noimage
Video❌ Novideo
Bookmark❌ Nobookmark
Divider✅ Yesdivider
Table❌ Notable
Table Row❌ Notable_row
Column❌ Nocolumn
Column List❌ Nocolumn_list
Audio❌ Noaudio
Synced Block❌ Nosynced_block
Table Of Contents❌ Notable_of_contents
Embed❌ Noembed
Figma❌ Nofigma
Google Maps❌ Nomaps
Google Drive❌ Nodrive
Tweet❌ Notweet
PDF❌ Nopdf
File❌ Nofile
Link❌ Notext (inline)
Page Link❌ Nopage
External Page Link❌ Notext (inline)
Collections❌ No-
Collection View❌ Nocollection_view
Collection View Table❌ Nocollection_view
Collection View Gallery❌ Nocollection_view
Collection View Board❌ Nocollection_view
Collection View List❌ Nocollection_view
Collection View Calendar❌ Nocollection_view
Collection View Page❌ Nocollection_view_page

This list will be continuously updated, and we plan to support more block types in the future.

Using Props

Notionpresso provides Props types for each block type. These Props types can be imported directly from the library for use.

For example, the Props for the Paragraph component can be imported and used as follows:

import { ParagraphProps } from "@notionpresso/react";


// Structure of ParagraphProps
interface ParagraphProps {
type: "paragraph";
paragraph: {
rich_text: Array<RichTextItemResponse>;
color: string;
};
id: string;
has_children?: boolean;
}




// Usage example
const MyParagraph: React.FC<ParagraphProps> = (props) => {
// Custom implementation
};

// Usage example const MyParagraph: React.FC<ParagraphProps> = (props) => { // Custom implementation };

Detailed structures of Props for each block type can be found in the respective block type documentation.

Applying Custom Components

One of the major advantages of Notionpresso is the ability to completely replace each block type with custom components. Here's how to apply custom components:

import { Notion } from "@notionpresso/react";
import CustomParagraph from "./CustomParagraph";
import CustomHeading from "./CustomHeading";


const customComponents = {
paragraph: CustomParagraph,
heading_1: CustomHeading,
heading_2: CustomHeading,
heading_3: CustomHeading,
// ... custom components for other block types
};




function MyNotionPage({ blocks }) {
return (
<Notion custom={customComponents}>
<Notion.Blocks blocks={blocks} />
</Notion>
);
}

function MyNotionPage({ blocks }) { return ( <Notion custom={customComponents}> <Notion.Blocks blocks={blocks} /> </Notion> ); }

The type of components injected into the Notion component is as follows:

type NotionComponents = Record<string, React.ComponentType<any>>;

Here, key is the type of Notion block (e.g., 'paragraph', 'heading_1', etc.), and value is the React component that will render that type.

Data Preprocessing

Notionpresso preprocesses block data fetched from the Notion API into a form optimized for UI rendering. In this process, it defines and uses a new type called ContextedBlock.

+----------------------+
|    Notion API        |
|    Block Data        |
| +------------------+ |
| | Block            | |
| | - id             | |
| | - type           | |
| | - has_children   | |
| | - [type_specific]| |
| +------------------+ |
+----------------------+
           |
           | (Input)
           v
+---------------------------+
| resolveToContextedBlocks  |
| +-------------------------+
| | For each block:         |
| | +---------------------+ |
| | |resolveToContextedBlo| |
| | |ck (recursive)       | |
| | +---------------------+ |
| |   |                     |
| |   v                     |
| | Map parent-child        |
| | relationships           |
| +-------------------------+
|   |
|   v
| Map sibling relationships |
+---------------------------+
           |
           | (Output)
           v
+---------------------------+
|     ContextedBlocks       |
| +-------------------------+
| | ContextedBlock          |
| | - ...Block properties   |
| | - context:              |
| |   - previous (sibling)  |
| |   - next (sibling)      |
| |   - parent              |
| | - blocks (children)     |
| +-------------------------+
+---------------------------+
           |
           | (Used by)
           v
    +----------------+
    | Notion.Blocks  |
    | Component      |
    +----------------+

ContextedBlock extends the existing Block type to include the following additional information:

  • Previous block (sibling relationship)
  • Next block (sibling relationship)
  • Parent block

This additional information can be useful in specific block components.

Rendering Process

The rendering process of Notionpresso is as follows:

+-------------------+      +------------------+
|   Custom          |      |   Default        |
|   Components      |      |   Components     |
+-------------------+      +------------------+
          |                         |
          |   +-----------------+   |
          +-->|     Notion      |<--+
              |    Component    |
              |(React.Provider) |
              +-----------------+
                    |     |
         +----------+     +------------+
         |                             |
+----------------+             +----------------+
| Notion.Cover   |             | Notion.Body    |
+----------------+             +----------------+
                                       |
                               +----------------+
                               | Notion.Title   |
                               +----------------+
                                       |
                               +----------------+
                               | Notion.Blocks  |
                               +----------------+
                                       |
                                       v
                               +----------------+
                               | Rendered       |
                               | Notion Page    |
                               +----------------+

Through this process, custom components and default components work together to render the Notion page.

Styling

The currently provided Notion components are implemented to closely resemble Notion's style. Each component is styled using CSS classes with the notion- prefix.

Future Plans

  • Add support for more block types
  • Develop component sets with applied themes
  • Expand advanced customization options

In the following pages, you can find detailed descriptions, Props structures, usage examples, and customization options for each block type.