# Prose

- Page: <https://kznlabs.github.io/labsUI/components/prose>

## Prose (`prose`, component)

Typography for a Markdown or MDX body: spacing, headings, lists, quotes, code, images and tables from tokens alone. Styles known tags as direct children or one `<section>` down, so a Card or demo placed inside keeps its own look; wide code blocks and tables scroll on their own, by keyboard too.

- Install: `npx @kznlabs/labsui add prose`
- Docs: <https://kznlabs.github.io/labsUI/components/prose>
- Brings: overflow-focus, utils
- npm: clsx@^2.1.1, tailwind-merge@^3.7.0

### API

- `<Prose>` (+ <div> props): Typography for a Markdown or MDX body: spacing, headings, lists, code, tables, tokens only. Wide
code blocks and tables scroll on their own and take keyboard focus while they do.
  - `as?: "div" | "article" | "section"` = `"div"`: The element to render; a blog post reads best as an `article`.

### Usage

```tsx
<Prose as="article"><h2>Release notes</h2><p>Clips now upload in the background.</p></Prose>
```

### Example: post.tsx

```tsx
import { Prose } from "@/components/ui/prose";

// Children: an MDX body, or your own markup.
export function Post() {
  return (
    <Prose as="article">
      <h2>Keeping clips after a match</h2>
      <p>Clips stay on your server until you delete them.</p>
    </Prose>
  );
}

// Rendered Markdown: sanitize it first if users wrote any of it.
export function RenderedPost({ html }: { html: string }) {
  return <Prose as="article" dangerouslySetInnerHTML={{ __html: html }} />;
}
```
