# Prose

Rich-text defaults for articles and long-form content.

Source: https://www.zazz.sh/api/primitives/prose/

## Installation

```bash
pnpm dlx zazz-ui add prose
```

Run `zazz-ui init` first if the project has no `zazz/` folder yet.

## Examples

### Default

```html
<article
  data-ui="prose"
  style="
    --py: 8;
    --mx: auto;
    --w: 100%;
    --max-w: var(--article-lg);
  "
>
  <hgroup>
    <span data-ui="text-eyebrow">Heading 1</span>
    <h1>How vexingly quick daft zebras jump.</h1>
    <p data-ui="text-xl" style="--text: var(--color-muted-foreground)">The Art of Typography</p>
  </hgroup>
  <hgroup>
    <span data-ui="text-eyebrow">Heading 2</span>
    <h2>How vexingly quick daft zebras jump.</h2>
  </hgroup>
  <hgroup>
    <span data-ui="text-eyebrow">Heading 3</span>
    <h3>How vexingly quick daft zebras jump.</h3>
  </hgroup>
  <hgroup>
    <span data-ui="text-eyebrow">Heading 4</span>
    <h4>How vexingly quick daft zebras jump.</h4>
  </hgroup>
  <hgroup>
    <span data-ui="text-eyebrow">Heading 5</span>
    <h5>How vexingly quick daft zebras jump.</h5>
  </hgroup>
  <hgroup>
    <span data-ui="text-eyebrow">Heading 6</span>
    <h6>How vexingly quick daft zebras jump.</h6>
  </hgroup>
  <hr />
  <p data-ui="text-xl">
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum
    mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis
    dolor.
  </p>
  <p data-ui="text-lg">
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum
    mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis
    dolor.
  </p>
  <p>
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum
    mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis
    dolor.
  </p>
  <p data-ui="text-sm">
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum
    mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis
    dolor.
  </p>
  <p data-ui="text-xs">
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum
    mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis
    dolor.
  </p>
  <hr />
  <figure>
    <img
      sizes="auto"
      loading="lazy"
      width="800"
      height="400"
      src="https://images.unsplash.com/photo-1564760055775-d63b17a55c44?auto=format&fit=crop&w=800&h=400&q=60"
      alt="Elephants crossing a floodplain at dusk"
    />
    <figcaption>Figure 1: An image and its caption, styled by data-ui="prose"</figcaption>
  </figure>
</article>
```

## Size and rhythm

Prose reads the global type controls, so retuning `--typeset-base-*`, `--typeset-scale-*`, or `--paragraph-spacing-multiplier` on `:root` changes every article. To size one article differently, give it a preset:

- `data-prose-size="sm"`: compact. 0.875 times the base, leading 1.5, and three quarters of the space between blocks. For dense docs and sidebars.
- `data-prose-size="lg"`: reading. 1.125 times the base, leading 1.8, and a quarter more space between blocks. For long-form articles.

A preset scales the base and recomputes the type scale for that article, so its headings, body text, and roles grow or shrink together, and your `:root` controls still apply. Kit components inside it read the same tokens, so they scale too. `data-prose-slot="end"` stops the prose margins on a component but not its size; set its size utility to pin that.

`--ui-prose-flow` multiplies the space between blocks without touching the type, on `:root` for every article or on one: `style="--ui-prose-flow: 1.5"`. It stacks on the preset's spacing and the global `--paragraph-spacing-multiplier`.

```html
<article data-ui="prose" data-prose-size="lg" style="--ui-prose-flow: 1.5">
  <h2>Roomy article</h2>
  <p>Larger text, looser leading, and the preset's spacing half again.</p>
</article>
```

## Opting out

Prose styles everything inside it. To embed a widget in an article (a form, a menu, a demo) without prose margins and list styles, put `data-prose-slot="end"` on its wrapper; prose picks up again after it.

```html
<article data-ui="prose">
  <p>Prose styles this paragraph.</p>
  <div data-prose-slot="end">
    <ul><li>But not this list.</li></ul>
  </div>
</article>
```

To turn prose back on deeper in that subtree, for a caption inside a widget, say, put `data-prose-slot="start"` on a wrapper inside it. Both slots work only inside `data-ui="prose"`. `data-prose-size` on a start slot does nothing.

```html
<article data-ui="prose">
  <div data-prose-slot="end">
    <ul><li>Not this list.</li></ul>
    <div data-prose-slot="start">
      <ul><li>This list again.</li></ul>
    </div>
  </div>
</article>
```

## Attributes

| Attribute | Kind | Values |
| --- | --- | --- |
| `data-prose-size` | preset | `lg` `sm` |
| `data-prose-slot` | slot | `end` `start` |
