Typography
Caption
Small, muted supporting text for figures, metadata and hints.
Purpose
Caption renders small supporting text (size sm, tone muted): figure captions, metadata,
field hints and error messages.
Import
import { Caption } from "@neshel-ui/typography";Usage
Preview: caption-figure
Updated a few minutes ago.
import { Stack } from "@neshel-ui/layout";
import { Caption, Paragraph } from "@neshel-ui/typography";
export default function CaptionFigure() {
return (
<Stack as="figure" space="2" className="m-0">
<div
className="h-24 rounded-lg bg-[var(--neshel-muted)]"
role="img"
aria-label="Revenue chart placeholder"
/>
<Caption asChild>
<figcaption>Figure 1 — Monthly revenue, last twelve months.</figcaption>
</Caption>
<Paragraph size="sm">
<Caption as="span" tone="default">
Updated
</Caption>{" "}
a few minutes ago.
</Paragraph>
</Stack>
);
}API
CaptionProps
| Prop | Type | Default | Description |
|---|---|---|---|
| align | Responsive<TextAlign> | — | Text alignment (logical: start/end). |
| as | E | — | — |
| asChild(required) | boolean | — | — |
| family | FontRole | — | Font role (Heading "display", Paragraph and Caption "body"; Text inherits). |
| leading | Responsive<TextLeading> | — | Unitless line height; defaults to the size's leading. Drives Capsize trimming. |
| measure | TextMeasure | — | Maximum line length: narrow 45ch, comfortable 65ch, wide 80ch. |
| ref | Ref<HTMLElement> | — | — |
| size | Responsive<TextSize> | — | Size token; font-size = token × the font role's cap-height scale. |
| tone | TextTone | — | Colour role paired with the background for contrast (Caption defaults to "muted"). |
| tracking | TextTracking | — | Letter spacing. |
| trim | boolean | true | Capsize trimming of the space above the cap height and below the baseline (default true). |
| truncate | boolean | — | One line with an ellipsis (clips overflow, so trimming is removed). |
| weight | Responsive<TextWeight> | — | Font weight; Heading defaults to "semibold". |
| wrap | TextWrap | — | Line wrapping strategy (balance suits headings, pretty paragraphs). |
Also accepts the props of: React DOM attributes.
CaptionElement
type CaptionElement = "p" | "span" | "div" | "small" | "figcaption"Accessibility
For a field hint or error, give the Caption an id and reference it from the control with
aria-describedby. Use tone="destructive" for errors, but never colour alone: say what is wrong.
Common mistakes
- Using Caption for headings of small sections: use
Headingwith a smallsize.