# MarkdownResponse

Formatted replies as they stream: headings, lists, tables, code, links and footnotes.

- **Use it for**: Formatted replies with headings, lists, tables, code and links.
- **Not for**: Plain streaming text where size matters. Try [StreamingResponse](https://unseenui.com/components/streaming-response/).

## Installation

```bash
npm install @stackunseen/ui react-markdown remark-gfm remend
```

## Usage

```tsx
import { MarkdownResponse } from '@stackunseen/ui/markdown';
import '@stackunseen/ui/styles.css';

<MarkdownResponse variant="cursor" text={markdown} state="complete" />
```

## Props

- `text` (`string`): The response so far. Update it as new text arrives.
- `state` (`MessageData['state']`): The response state from your application, including streaming or complete.
- `headingLevel` (`1 | 2 | 3 | 4 | 5 | 6 (optional)`): Heading level for a Markdown # heading. Defaults to 3; deeper headings stop at 6.
- `renderCodeBlock` (`(props: MarkdownCodeBlockProps) => ReactNode (optional)`): Render fenced code with your own component. Define this callback in your application.

## All props

| Prop | Type | Description |
| --- | --- | --- |
| `citations` | `readonly Source[]` | Sources the text cites as [1], [2] and so on, in that order. |
| `error` | `string` |  |
| `followUps` | `readonly FollowUp[]` | Short next steps offered once the response is complete. |
| `headingLevel` | `3 \| 2 \| 1 \| 4 \| 5 \| 6` | HTML level for a source # heading. |
| `onFollowUp` | `((item: FollowUp) => void)` |  |
| `onStop` | `(() => void)` | With progress: a Stop action beside the line. |
| `progress` | `ResponseProgress` | Where a multi-step answer stands, as your server reports it: "Writing 2 of 3 · 142 → 46". |
| `renderCodeBlock` | `((props: MarkdownCodeBlockProps) => ReactNode)` | Trusted application renderer for fenced code; Markdown cannot supply executable UI. |
| `showStatus` | `boolean` | Composite messages announce status once at the message boundary. |
| `state` (required) | `MessageState` |  |
| `text` (required) | `string` |  |
| `variant` | `"cursor" \| "dots" \| "shimmer"` |  |

## Keyboard

Tab reaches links and code actions. Wide code blocks can be scrolled with the keyboard. Set headingLevel to fit the page outline.

## Works with

[MarkdownCodeBlock](https://unseenui.com/components/markdown-code-block/), [RichMarkdownResponse](https://unseenui.com/components/rich-markdown-response/), [MathFormula](https://unseenui.com/components/math-formula/), [MermaidDiagram](https://unseenui.com/components/mermaid-diagram/)

Page: https://unseenui.com/components/markdown-response/
