Skip to content

Content

Prose

Rendered markdown or rich text, sized to fit chat bubbles, panels and reading views.

import { Prose } from '@var-ui/react';

Build fixed

The failure came from a stale dist folder. I rebuilt core and the tests pass again:

Shell
vp run build
vp test run
  • 2,642 tests passed
  • See the CI run for details

Prose

Styles the bare HTML a markdown renderer emits (headings, paragraphs, lists, links, inline and fenced code, blockquotes, tables, rules) for use inside app UI: an agent reply in a chat bubble, a trace panel, a note, a description field.

Everything is relative to the surrounding font size, so Prose takes the size of whatever it sits in. Headings use the body font at a modest scale.

Examples

Compact, in a chat bubble

Build fixed

The failure came from a stale dist folder. I rebuilt core and the tests pass again:

Shell
vp run build
vp test run
  • 2,642 tests passed
  • See the CI run for details
Demo.tsxTSX
import Markdown from 'react-markdown';
import remarkGfm from 'remark-gfm';
import { ChatMessage, ChatMessageBubble, Prose, proseComponents } from '@var-ui/react';

<ChatMessage sender="assistant">
  <ChatMessageBubble>
    <Prose density="compact">
      <Markdown remarkPlugins={[remarkGfm]} components={proseComponents}>
        {reply}
      </Markdown>
    </Prose>
  </ChatMessageBubble>
</ChatMessage>

Density

density sets the vertical rhythm and heading scale:

  • compact: chat bubbles, cards, table cells. Tight gaps; headings barely larger than text.
  • balanced (default): side panels and detail views.
  • spacious: reading views and long notes. Roomier gaps, larger headings, relaxed line height.

Markdown renderers

proseComponents maps elements to Var UI components for any renderer that takes a components prop (react-markdown, MDX):

ElementRendersWhy
pre (fenced code)CodeBlockCopy button; the language comes from the language-* class.
code (inline)CodeSame chip as the rest of the app.
aLinkClient-side routing through RouterProvider.
table, thead, tbody, tr, th, tdTable partsHorizontal scrolling, Table styles, and GFM column alignment as align.
TSX
import Markdown from 'react-markdown';
import remarkGfm from 'remark-gfm';
import { Prose, proseComponents } from '@var-ui/react';

<Prose density="compact">
  <Markdown remarkPlugins={[remarkGfm]} components={proseComponents}>
    {reply}
  </Markdown>
</Prose>;

Override one entry by spreading: components={{ ...proseComponents, a: MyLink }}. The mapping is optional: without it, Prose still styles the bare elements, so HTML rendered on a server works as is.

How it composes

Prose’s element rules live in the base cascade layer, below components. A Var UI component inside Prose (mapped by proseComponents or placed by hand) always keeps its own styles, with no data-not-prose and no specificity contest with your own classes. You only need data-not-prose for markup that isn’t a Var UI component.

Opting out

Mark anything that shouldn’t take prose styles with data-not-prose: a live demo, an embedded widget, a hand-built table. Prose skips the element and everything inside it. The element itself still gets the space between blocks, so it sits in the flow like any other block. Var UI components don’t need it, because their own styles already win.

TSX
<Prose>
  <Markdown>{intro}</Markdown>
  <div data-not-prose>
    <MyChart />
  </div>
</Prose>

To add your own element rules on top of prose, wrap them in proseRules() from @var-ui/core so they honour data-not-prose too.

Astro

Prose from @var-ui/astro renders the same <div> and class; wrap rendered markdown (<Content />) in it. In plain HTML, put class="var-ui-prose" and data-density="compact" on the wrapper.

Props

All native <div> attributes are passed through, and ref is the div.