Skip to contentnotionic
Docs menu

Guides

Customizing blocks

Replace the component for any block type.

Pass components to replace the built-in component for any block type:

TypeScript
import { NotionRenderer, RichText, type BlockProps } from "notionic"
function Callout({ block, context, children }: BlockProps<"callout">) {  return (    <aside className="rounded-lg border p-4">      <RichText text={block.callout.rich_text} context={context} />      {children}    </aside>  )}
<NotionRenderer blocks={blocks} components={{ callout: Callout }} />

What a component gets

  • block: the block, typed for its type, so block.callout is typed.
  • children: the block's nested blocks, already rendered, or undefined.
  • context: pass it to RichText and other helpers, so links and headings resolve the same way everywhere.

Equations inside text

Equations inside text have their own key, inline_equation, whose component gets the LaTeX as expression:

TypeScript
<NotionRenderer  blocks={blocks}  components={{ inline_equation: ({ expression }) => <code>{expression}</code> }}/>

Links

Every link in text renders through components.link. It gets the resolved link ({ href, external }), the text as children, and, when linkFavicons is on, the site's favicon. Draw your own icon for some sites and keep the default for the rest:

TypeScript
import { LinkFavicon, type LinkProps } from "notionic"
function Link({ link, favicon, children }: LinkProps) {  const github = link.href.startsWith("https://github.com/")  return (    <a href={link.href} target={link.external ? "_blank" : undefined}>      {github ? <GitHubIcon /> : <LinkFavicon favicon={favicon} />}      {children}    </a>  )}
<NotionRenderer blocks={blocks} linkFavicons components={{ link: Link }} />

Reusing the defaults

defaultComponents holds the built-in components, to wrap or fall back to:

TypeScript
import { defaultComponents } from "notionic"
const Code = defaultComponents.code!