# Prose

Styles the headings, text, lists, code and tables inside it, such as rendered Markdown.

Source: [prose.tsx](https://github.com/jakejarvis/jarvis-ui/blob/main/src/components/ui/prose.tsx)

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

export default function ProseArticle() {
  return (
    <Prose className="max-w-lg">
      <h2>Release notes</h2>
      <p>
        Deploys now roll out region by region, and a failed health check stops the rollout before it
        reaches every user. Read more in the <a href="#rollouts">rollouts guide</a>.
      </p>
      <ul>
        <li>
          Set <code>rollout.regions</code> to choose the order.
        </li>
        <li>
          <strong>Pause</strong> a rollout from the dashboard at any time.
        </li>
      </ul>
      <blockquote>
        Existing projects keep deploying everywhere at once until they opt in.
      </blockquote>
    </Prose>
  );
}
```

## Installation

Add the registry, once per project:

```bash
npx shadcn@latest registry add @jarvis=https://ui.jarv.is/r/{name}.json
```

Then add the component:

```bash
npx shadcn@latest add @jarvis/prose
```

## Usage

Wrap content whose elements you don't write yourself, such as the HTML that a Markdown renderer or
a CMS returns.

```tsx
import Markdown from "react-markdown";

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

export function Post({ body }: { body: string }) {
  return (
    <Prose>
      <Markdown>{body}</Markdown>
    </Prose>
  );
}
```

Prose styles its direct children and the text inside them, so a component placed in it, or anything
marked `not-prose`, keeps its own styles. Its rules add no specificity, so a class on an element
inside it takes precedence.

A table fills the width and wraps long words in its cells, but one with many columns can still
overflow on a phone. Wrap it in a [Scroll Area](https://ui.jarv.is/components/scroll-area.md), as
[Markdown](https://ui.jarv.is/components/markdown.md) does, so it scrolls horizontally instead.

## Examples

### With components

```tsx
import { Kbd, KbdGroup } from "@/components/ui/kbd";
import { Prose } from "@/components/ui/prose";
import {
  Table,
  TableBody,
  TableCell,
  TableHead,
  TableHeader,
  TableRow,
} from "@/components/ui/table";

export default function ProseWithComponents() {
  return (
    <Prose className="max-w-lg">
      <p>
        Press{" "}
        <KbdGroup>
          <Kbd>⌘</Kbd>
          <Kbd>K</Kbd>
        </KbdGroup>{" "}
        to search the <a href="#shortcuts">shortcuts</a>.
      </p>
      <Table>
        <TableHeader>
          <TableRow>
            <TableHead>Action</TableHead>
            <TableHead>Shortcut</TableHead>
          </TableRow>
        </TableHeader>
        <TableBody>
          <TableRow>
            <TableCell>New project</TableCell>
            <TableCell>
              <Kbd>N</Kbd>
            </TableCell>
          </TableRow>
          <TableRow>
            <TableCell>Settings</TableCell>
            <TableCell>
              <Kbd>,</Kbd>
            </TableCell>
          </TableRow>
        </TableBody>
      </Table>
      <div className="not-prose">
        <a href="#unstyled">This link</a> keeps the page's own styles.
      </div>
    </Prose>
  );
}
```

## Props

| Part | Extends |
| --- | --- |
| `Prose` | `<div>` |

Base UI's [styling](https://base-ui.com/react/handbook/styling) and [composition](https://base-ui.com/react/handbook/composition) guides say more about `className`, `style` and `render`.

### Prose

| Prop         | Type                                                     | Default | Description                                                                                                                                                                               |
| ------------ | -------------------------------------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `className?` | `string`                                                 | —       | CSS class applied to the element.                                                                                                                                                         |
| `style?`     | `React.CSSProperties`                                    | —       | Style applied to the element.                                                                                                                                                             |
| `render?`    | `ComponentRenderFn<HTMLProps, {}> \| React.ReactElement` | —       | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
