Rich Text on Avalonia, Built for SpeedNews

Rich Text on Avalonia, Built for Speed

The RichTextEditor with a "Designing for Speed" document open, showing the toolbar, a styled title, body paragraphs, a bulleted list, and a selected word.

For years, the request has come up again and again on the Avalonia issue tracker, in chat rooms, in forum threads: when do we get rich text? TextBox is a great input control, but it's not a RichTextBox. And anyone trying to build a notes app, a documentation tool, a chat client with formatting, or anything resembling a word processor was left without a clear path forward.

Today I'm sharing the answer: RichTextEditor — and it's more than a RichTextBox equivalent. It's a complete editor framework for Avalonia, built around real document formats, designed for performance from the ground up, and open to extension at every layer.

More than a control — a framework

The point I want to be clear about up front: this isn't just "Avalonia finally has a RichTextBox."

RichTextEditor is the visible control, but underneath it is a full document framework. You can work with RTF, DOCX, and XAML documents directly — load them, edit them, save them, round-trip them. Plain text is supported, and rich content import works through the clipboard so paste-from-browser does what users expect.

The formats that ship in the box are the common ones, but they aren't a fixed list. The serialization layer is open by design: adding a new document format — Markdown, ODT, a proprietary in-house format, whatever your application needs — means implementing one interface. No forking, no waiting for upstream.

This matters because rich text in a real application is rarely just about displaying formatted text. It's about exchanging it: with Word users, with existing document libraries, with email systems, with the rest of your data pipeline. RichTextEditor is built to live in that world.

A single paragraph showing bold, italic, subscript, superscript, a highlighted phrase, strikethrough, a hyperlink, and inline code styling — all rendered inline with body text.

One paragraph, every inline style.

The long road here

This control is the final step of a longer journey. Rich text on a cross-platform UI framework needs a lot of pieces to exist before the editor itself can be built — text measurement, inline flow, document primitives, layout. Those came first, contribution by contribution, over several years. RichTextEditor is what they were always pointing toward.

Fast, by design

The other thing users asked for, every time the topic came up, was that it had to be fast. Rich text editing has a reputation for being slow — big documents lag, typing stutters, saving freezes the window. I didn't want to ship another one of those.

Performance wasn't a feature to add later. It was the constraint everything else had to fit around.

Markdown streaming live into the editor. The framework re-renders incrementally as content arrives — no flicker, no full reflows.

The editor uses virtualization throughout. A document can contain thousands of paragraphs, but the user only sees a few dozen at a time — so those are the only ones paying the cost of being on screen. The same principle runs deeper than rendering: text storage, document structure, position tracking, undo history are all built around the same idea. Do the minimum work, on the smallest piece of the document, at the latest possible moment.

In practice, that means:

  • Typing stays responsive on documents large enough to make other editors crawl.
  • Scrolling is smooth regardless of document length.
  • Saving doesn't freeze the UI. Export to RTF, DOCX, or XAML happens in the background — you keep typing while the file is written.
  • Undo is cheap. A long edit session doesn't quietly eat your memory.

These aren't micro-optimizations bolted on at the end. They fall out of the architecture.

Pluggable at every layer

The framework is built as a stack of distinct layers, each with a clean public surface. You can use the whole stack as a finished editor — drop it in a window, give it a document, done. Or you can reach into any single layer and replace, extend, or wrap it:

  • The document model is the storage layer. Use it on its own if you just need a fast, structured text data structure.
  • The rendering layer can be used without the editor on top — there's a read-only document viewer for display-only scenarios.
  • The editing layer is component-based. Keyboard handling, mouse handling, caret behavior, selection — each is a swappable piece. Want vim-style keybindings? Replace the keyboard component. Want a custom caret? Replace the caret component.
  • The highlight system is open. Selection rendering is one highlight layer; you can add your own for find-and-replace, spell check, syntax highlighting, collaborative cursors — anything that needs to draw on top of text.
  • The serialization layer is extensible. RTF, DOCX, XAML, and plain text ship in the box; any format you need beyond that is one interface away.
  • The undo system records your own custom operations alongside the built-in ones.

An amber callout block labeled "HEADS UP" — a warm-toned styled Section with a left bar, used for warnings or tips.

Callouts, notes, tips, and warnings — every styled block in the document is built from the same Section primitive.

Every layer has a documented public API. Every layer can be customized without forking. And because each layer is independent, you only take on the complexity of the parts you actually touch.

A styled pull-quote rendered by the editor — soft blue background, dark blue left bar, italic text, with a small "From the design notes" attribution beneath.

A pull-quote authored as a styled Section — same primitive, restyled to fit the document.

What's in the box

A complete editing experience, out of the box:

  • A rich document model with paragraphs, sections, lists, hyperlinks, and inline runs — including the ability to embed arbitrary Avalonia controls inline with text
  • Advanced table editing — non-destructive, with merged cells and per-cell formatting, directly in the editor
  • Caret, selection, keyboard, and mouse behavior that matches what users expect
  • Undo and redo with sensible defaults
  • Import and export for RTF, DOCX, XAML, and plain text, plus rich content import via clipboard
  • A toolbar and action system with the common formatting commands ready to use
  • Light and dark themes out of the box
  • A read-only document viewer for when you only need display
  • A separate Markdown control for rendering Markdown, with optional syntax-highlighting integrations

And underneath it, a foundation you can build on when "out of the box" isn't enough.

A styled "Quarterly Plan" table showing initiatives, owners, dates, progress percentages, and colored status pills (Shipped, On track, At risk, Blocked, Planned), with a merged summary row at the bottom.

A planning table authored as a single FlowDocument. Five status colors, a merged summary row, and per-cell styling — no template hacks.

Availability and Licensing

RichTextEditor is included with Avalonia's Pro subscription tier. You can see the current plans on the Avalonia pricing page.

Get Started

Install the package:

dotnet add package Avalonia.Controls.RichTextEditor

Add your license key to the executable project's .csproj:

<ItemGroup>
    <AvaloniaUILicenseKey Include="YOUR_LICENSE_KEY" />
</ItemGroup>

Add the editor theme to your App.axaml:

<Application.Styles>
    <FluentTheme />
    <StyleInclude Source="avares://Avalonia.Controls.RichTextEditor/Themes/Default.axaml"/>
</Application.Styles>

Drop the editor into your XAML:

<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <RichTextEditor>
        <FlowDocument>
            <Paragraph>
                <RichRun Text="Welcome to "/>
                <RichRun Text="RichTextEditor" FontWeight="Bold"/>
                <RichRun Text="."/>
            </Paragraph>
        </FlowDocument>
    </RichTextEditor>
</Window>

That's it. You have a working rich text editor with toolbar, formatting commands, undo/redo, clipboard, and import/export for RTF, DOCX, XAML, and plain text.

For the full API and customization guides, see the documentation.

If you've been waiting for a serious rich text story on Avalonia — it's here.