Skip to main content

Overview

The MathBlock plugin provides standalone, display-mode math equations rendered with KaTeX. Unlike MathInline, which appears inline within text, MathBlock creates a dedicated block for larger equations that are centered and rendered in display mode. Both plugins are part of the @yoopta/math package, following the same pattern as Code / CodeGroup from @yoopta/code.

Installation

You also need KaTeX CSS for proper rendering:

Basic Usage

Pass the plugin to createYooptaEditor (wrapped with withMath).
To use both inline and block math together:

Features

  • Display-mode equations rendered with KaTeX (centered, larger font)
  • Standalone block — not inline within text
  • Click to edit, with live KaTeX preview
  • Copy LaTeX source to clipboard
  • HTML, Markdown, and email serialization
  • Dark mode support

Using with Themes

The @yoopta/themes-shadcn package includes a styled MathBlock component with a card-based edit UI.
The shadcn theme provides:
  • Preview mode — centered display-mode rendering with hover overlay (copy + edit buttons)
  • Edit mode — larger textarea with live preview, save/cancel/delete actions
You can also apply the theme to just the MathBlock plugin:

Element Props

Commands

Import commands: import { MathBlockCommands } from '@yoopta/math'

buildMathBlockElement

Creates a math block element structure without inserting it.

updateMathBlock

Updates the LaTeX expression of an existing math block.

getMathBlockElement

Finds the math-block element in a given block.

openEditor / closeEditor

Controls the edit state (requires withMath extension). Shared with MathInline.

Editor Extension

MathBlock shares the same withMath extension as MathInline. See the MathInline docs for details.

Parsers

HTML

Serializes to <div data-math-block data-latex="..."> with KaTeX-rendered content inside (display mode). Deserializes from <div data-math-block> elements, reading the data-latex attribute.

Markdown

Serializes to block math syntax:

Email

Serializes with display-mode KaTeX HTML output wrapped in a centered div for email clients.

LaTeX Examples

Common display-mode expressions:

MathInline

Inline math expressions within text

Code

Code blocks (another void block plugin)