<!-- Generated by scripts/gen-docs.mts from the JSDoc in registry/. Do not edit; run `pnpm run docs`. -->

# Markdown

An agent's reply, written in Markdown, drawn with Ouro's own parts: headings, paragraphs, lists, quotes, tables and rules, with bold, italic, strikethrough, inline code and links; fenced code is a CodeBlock with Copy. It builds React elements and never HTML: raw HTML in the reply shows as text, a link opens only to an `http:`, `https:` or `mailto:` address, and an image stays its words as a link to it, so the reply never makes the page fetch or run anything. While it streams in, an emphasis or code mark with no closing mark yet stays text and an open fence is code so far, so the reply never flips between plain and formatted. It takes the size of the text around it.

## Install

Once per app, with Tailwind CSS v4 and an `@/*` path alias (skip `init` in an existing shadcn app), then the component:

```sh
npx shadcn@latest init --base base --preset nova --yes --no-monorepo
npx shadcn@latest add ourostack/ouro-ui/ouro-base#v1.3.823
npx shadcn@latest add ourostack/ouro-ui/markdown#v1.3.823
```

More: [Installing](https://ui.ouroboros.bot/docs/installing.md).

```tsx
import { Markdown } from "@/components/ouro/markdown/markdown";
```

## Example

```tsx
<Markdown streaming={!done}>{reply}</Markdown>
```

## Use instead when

- Use `Text` instead for the app's own words, and `CodeBlock` alone for code that isn't part of a reply.

## Props

Type: `MarkdownProps`.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `children` (required) | `string` |  | The agent's reply, as Markdown text. |
| `className` | `string` |  | Layout only: margins, width (`mt-2`). Appearance classes warn in development. |
| `headingLevel` | `2 \| 3 \| 4 \| 5 \| 6` | `3` | The heading level of a `#` in the reply, one below the section's heading; `##` is one more. |
| `links` | `boolean` | `true` | Whether a link opens. With `false` every link shows as its words alone, for apps whose agent text must stay data. |
| `ref` | `Ref<HTMLDivElement>` |  | Reaches the rendered element. |
| `streaming` | `boolean` |  | Whether the reply is still coming in. It marks the reply busy, and code whose closing fence hasn't arrived yet has no Copy until it does. |

## Don't use

These are not props. Passing one fails the type check with the fix in the error, and in development a console message names the fix.

- `allowHtml`: Not a prop. Markdown never renders HTML; raw HTML in the reply shows as text.
- `content`: Not a prop. The Markdown is the children: `<Markdown>{reply}</Markdown>`.
- `dangerouslySetInnerHTML`: Not a prop. Markdown never renders HTML; raw HTML in the reply shows as text.
- `source`: Not a prop. The Markdown is the children: `<Markdown>{reply}</Markdown>`.
- `text`: Not a prop. The Markdown is the children: `<Markdown>{reply}</Markdown>`.

## `className` is for layout only

Pass margins, width and grid placement (`mt-4`, `w-full`, `col-span-2`).

Appearance comes from props, not classes. In development, a class that sets appearance logs one warning per component instance, naming the prop to use instead. A class sets appearance when, after its variants (`hover:`, `sm:`) and any `!` are removed, it starts with `bg-`, `text-`, `border-`, `rounded-`, `shadow-`, `font-`, `ring-`, `from-`, `via-`, `to-`, `fill-` or `stroke-`, or is `border`, `rounded`, `shadow` or `ring`, or has a `dark:` variant. Text wrapping, overflow and table layout classes (`text-wrap`, `text-ellipsis`, `border-collapse`) are layout and do not warn.

Alignment classes (`text-center`) warn too: set alignment on a parent element.
