FigureCaption
An editorial figure label, caption, and provenance that wraps on narrow screens.
Del dato a la idea
Menos ruido. Más señal.
JBM · Datos ilustrativos
Install
npx shadcn@latest add @jbm/figure-captionNeeds the @jbm entry in components.json; see Install once.
Also installs @jbm/tokens.
Usage
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>Props
- Stage
fluidWidth 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.
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">.
QA checks
- 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.