# FigureCaption (figure-caption)

> An editorial figure label, caption, and provenance that wraps on narrow screens.

- Entry: component
- Category: UI
- Preview capabilities: none (still preview)
- Runtime: React
- Needs Remotion: no
- QA page: https://jbm-ui.bns.studio/c/figure-caption
- JSON: https://jbm-ui.bns.studio/catalog/figure-caption.json
- Registry item: https://jbm-ui.bns.studio/r/figure-caption.json (source code in files[].content)

## Install

```sh
npx shadcn@latest add @jbm/figure-caption
```

Also installs @jbm/tokens (registry dependencies install automatically).

## Required setup

1. Add the `@jbm` registry to components.json (keep any entries already there):

   ```json
   {
     "registries": {
       "@jbm": "https://jbm-ui.bns.studio/r/{name}.json"
     }
   }
   ```

2. Map `@/*` to `./src/*` in tsconfig.json `compilerOptions.paths`, so `@/jbm/…` imports resolve to src/jbm/.

## Files

Each file's source code is in the registry item JSON (https://jbm-ui.bns.studio/r/figure-caption.json, files[].content).

| Source path | Installs to | Import |
| --- | --- | --- |
| `registry/jbm/ui/figure-caption.tsx` | `src/jbm/ui/figure-caption.tsx` | `@/jbm/ui/figure-caption` |

## API

### `FigureCaption` (component)

A <figcaption> with a hairline top rule: an optional vermilion `Fig. <index>` label, the caption text (18px bold), and optional mono provenance below. Place it as the first or last child of a <figure>; figcaption attributes and ref pass through.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `index` | `React.ReactNode` | none | Figure number or label, rendered as `Fig. <index>` in uppercase vermilion mono. Omit (null/undefined) to hide. |
| `provenance` | `React.ReactNode` | none | Optional source or credit line under the caption, 12px dim mono. |
| `layout` | `"inline" \| "stacked"` | `"inline"` | "inline" places the label beside the caption and wraps below it when narrower than about 180px of caption room; "stacked" always puts the label above. |

Also accepts React.ComponentPropsWithRef<"figcaption">.

## Stage

fluid: Width fills the figure. Height is 18px top padding plus the 1px border, the caption lines (18px × 1.4), and optional provenance (8px + 12px × 1.6 per line); stacked layout, or inline layout that wraps, adds the label line plus a 10px gap.

## Examples

### Caption a chart

```tsx
import { FigureCaption } from "@/jbm/ui/figure-caption"

<figure>
  <img src="/chart.png" alt="Descripción del gráfico" />
  <FigureCaption index="01" provenance="Fuente: nuestro estudio">
    Menos ruido. Más señal.
  </FigureCaption>
</figure>
```

## QA

- Compare inline and stacked layouts; in inline, narrow the screen until the caption wraps below the label without overlap.
- Check with and without index and provenance: no empty gaps appear when either is omitted.
- Confirm it is used inside a <figure> so the caption is associated with the visual.

## Related

Installs:

- [Tokens (tokens)](https://jbm-ui.bns.studio/catalog/tokens.md)

## More

- [llms.txt](https://jbm-ui.bns.studio/llms.txt): index of every item
- [catalog.json](https://jbm-ui.bns.studio/catalog.json): every item as JSON
- [Agent contract](https://jbm-ui.bns.studio/docs/agent-contract.md): what each field means
