# MarkdownMessage

> Markdown renderer (GFM, raw HTML skipped) for chat replies and long-form content; it renders plain HTML elements by default and maps them onto Title, Text and Link only with renderWithDesignSystem.

- Status: stable
- Group: structure
- Page: https://www.digitaltableteur.com/design-system/components/markdown-message
- Contract: https://www.digitaltableteur.com/contracts/v1/MarkdownMessage.contract.json

## When to use

Markdown renderer (GFM; raw HTML is skipped) for chat replies and long-form content. By default it renders plain p, h1-h3, a, strong and em elements styled by its own stylesheet; set renderWithDesignSystem to map them onto Title, Text and Link instead. Code and block code always render as plain code and pre elements, and density=chat drops images.

## When not to use

The contract records no forbidden uses.

## Look-alikes

The contract names no look-alike with a deciding condition.

## Props

| Prop | Type | Default | Description | Required |
| --- | --- | --- | --- | --- |
| `content` | `string` | none | Markdown source. Rendered through DS typography only when renderWithDesignSystem is set. | Yes |
| `fallback` | `string` | none | Plain text shown when content is empty after trimming. There is no parse-failure path. | No |
| `data-role` | `string` | none | No description in the contract. | No |
| `renderWithDesignSystem` | `boolean` | `false` | Render markdown using the design system components (Title/Text/Link). Useful for long-form content pages to ensure consistent styling. Defaults to `false`, which renders raw p, h1-h3, a, strong and em elements; code and pre stay plain elements in both modes. | No |
| `designSystemTextSize` | `DesignSystemTextSize` | `m` | When `renderWithDesignSystem` is enabled, use this as the base size for paragraph and inline emphasis text (e.g. `p`, `strong`, `em`). Defaults to `m`. | No |
| `density` | `"default" \| "chat"` | `default` | Compact typography for in-chat assistant replies. Defaults to `default`; `chat` also drops every image. | No |

## Variants

- Available densities: `default`, `chat` (default `default`).

## Invalid combinations

The contract records no invalid combinations.

## Keyboard

| Key | Behaviour |
| --- | --- |
| Tab | Reaches rendered links and block code; a pre is focusable (tabIndex 0) so its horizontal scroll is keyboard-reachable. |

## Rules

Every item under When not to use is a MUST NOT. MUST and SHOULD follow RFC 2119.

| Level | Rule | How it is checked |
| --- | --- | --- |
| MUST | ARIA: The root is an aria-live=polite region for the whole lifetime of the instance, so a reply that streams into an existing, initially empty instance is announced; content present at mount is not announced. | Not yet verified: no evidence record. WCAG 4.1.2. |
| MUST | ARIA: Density=chat drops every image; otherwise markdown images render as lazy img elements with their alt text (empty when the markdown gives none) | Not yet verified: no evidence record. WCAG 4.1.2. |
| MUST | Required stories produce no axe violations at the configured severity. | Automated by `npm run test:stories:matrix:ci`. WCAG 2.5.8. |
| MUST | The accessibility tree (role, name, state) matches the committed snapshot for every required story. | Automated by `npm run test:stories:matrix:ci`. WCAG 1.3.1, 4.1.2. |
| MUST | The component remains legible and operable under a real browser forced-colors: active pass. | Automated by `npm run test:stories:hc`. |
| MUST | Every documented keyboard interaction works as specified. | Not yet verified: no evidence record. WCAG 2.1.1, 2.1.2. |
| MUST | A human completed an end-to-end accessibility review of this component. | Manual review, last on 2026-11-04. |
| MUST NOT | Maintainers: Do not bypass design tokens or skip forced-colors verification at beta. | Release review; not machine-checked. |

## Install and import

- In-repo only. MarkdownMessage is not exported from `@digitaltableteur/react`, so there is no public import path.

## Links

- Machine-readable contract (Design System Contract 1.0): https://www.digitaltableteur.com/contracts/v1/MarkdownMessage.contract.json
- Markdown version of this page: https://www.digitaltableteur.com/design-system/components/markdown-message.md
- Component index as JSON: https://www.digitaltableteur.com/design-system/components.json
- All components: https://www.digitaltableteur.com/design-system/components
- Source: The implementation lives in a private repository. This page, its Markdown twin and the contract are generated from it at build time and are the public source of truth.
