component
Figure
A picture, a chart or a drawing with a line about it underneath: the media on a grey plate with 12px corners, the caption in label type.
Defaultimport { Figure } from 'rost/components/figure/Figure'
<Figure caption="Payments come in faster after the reminder.">
<img src={chart} alt="Days to payment, before and after the reminder" />
</Figure> src/components/figure/Figure.tsx
import type { HTMLAttributes, ReactNode } from 'react'
import './figure.css'
export interface FigureProps extends HTMLAttributes<HTMLElement> {
/** The picture, chart or drawing. */
readonly children: ReactNode
/** One or two lines on what it shows. */
readonly caption?: ReactNode
}
const b = 'rost-figure'
/** Media with a line about it underneath. Built from contracts/figure.contract.yaml. */
export function Figure({ children, caption, className, ...rest }: FigureProps) {
return (
<figure className={[b, className].filter(Boolean).join(' ')} {...rest}>
<div className={`${b}__media`}>{children}</div>
{caption != null && <figcaption className={`${b}__caption`}>{caption}</figcaption>}
</figure>
)
}
The source for everything on this page: contracts/figure.contract.yaml (opens in a new tab). The CSS, the docs and the checks in each app are built from it.
# yaml-language-server: $schema=../schema/component-contract.schema.json
schemaVersion: 2
id: figure
name: Figure
kind: component
status: review
summary: "A picture, a chart or a drawing with a line about it underneath: the media on a grey plate with 12px corners, the caption in label type."
category: display
related: [ card, illustration, hero-media ]
source:
tool: figma
fileKey: 1Zy0wiWKXQAvsfDBX3KR0d
nodeId: "748:28"
url: https://www.figma.com/design/1Zy0wiWKXQAvsfDBX3KR0d/UI-Kit-v01?node-id=748-28
extractedAt: "2026-11-17"
extractedBy: hand
frozenAt: "2026-11-17"
props:
children: { type: slot, required: true, notes: "The picture, chart or drawing. An `<img>` fills the plate's width." }
caption: { type: slot, notes: "One or two lines on what it shows." }
elements:
root:
notes: "A `<figure>`: the plate, then the caption, 8px apart."
styles:
display: { value: flex, assert: false }
flex-direction: { value: column, assert: false }
gap: { token: spacing/gap/small, value: 8px }
margin: { token: spacing/gap/none, value: 0px }
media:
notes: "The plate, in Card's grey, with 12px corners that clip what's in it. Whatever's smaller than it sits in the middle."
styles:
display: { value: flex, assert: false }
align-items: { value: center }
justify-content: { value: center }
overflow: { value: hidden, assert: false }
border-radius: { token: spacing/radius/medium, value: 12px }
background: { token: figure/media, value: "#171717" }
caption:
optional: true
notes: "The `<figcaption>`, in label type and the tertiary grey."
styles:
font-family: { token: font-family/base, value: "'General Sans Variable'" }
font-weight: { token: typography/label/font-weight/regular, value: "400" }
font-size: { token: typography/label/font-size, value: 12px }
line-height: { token: typography/label/line-height, value: 14px }
letter-spacing: { token: typography/label/letter-spacing, value: 0px }
color: { token: figure/caption, value: "#999999" }
guidance:
status: proposed
use:
- title: Something to look at, with a word on it
text: "A screenshot in a case study, a chart in a report, a diagram in the docs. The caption says what to notice."
avoid:
- title: Decoration
text: "A picture that's only there for mood needs no caption and no plate. That's **HeroMedia** or the image on its own."
behaviour: "It lays the media on its plate and the caption under it. It doesn't size the picture: an `<img>` gets the plate's width, anything else keeps its own size and sits in the middle."
accessibility:
element: "`<figure>` with a `<figcaption>`, so the caption is read as the figure's description."
name: "The image still needs its own `alt`. The caption adds to it, it doesn't replace it."
colour: "The caption is 7:1 on the dark page."
content: "Say what to see, not what it is: Payments come in faster after the reminder, rather than Chart of payments."
Install
npx github:Runceanu/rost add figure It lands in src/rost/figure/, with what it needs and its contract. Install has the rest.
When to use
Something to look at, with a word on it
A screenshot in a case study, a chart in a report, a diagram in the docs. The caption says what to notice.
When not to use
Decoration
A picture that's only there for mood needs no caption and no plate. That's HeroMedia or the image on its own.
Behaviour
It lays the media on its plate and the caption under it. It doesn't size the picture: an <img> gets the plate's width, anything else keeps its own size and sits in the middle.
Accessibility
- Element
<figure>with a<figcaption>, so the caption is read as the figure's description. - Name
The image still needs its own
alt. The caption adds to it, it doesn't replace it. - Colour
The caption is 7:1 on the dark page.
Content
Say what to see, not what it is: Payments come in faster after the reminder, rather than Chart of payments.
Props
| Prop | Type | Values | Default |
|---|---|---|---|
children | slot | | |
caption | slot | | |
Values
Straight from the contract. Each value sits next to its token, because six tokens here all come out as #3a3a3a and the colour alone can't tell you which one is right.
Never changes
root
-
gap8pxspacing/gap/small -
margin0pxspacing/gap/none
displayflex · flex-directioncolumn
media
-
border-radius12pxspacing/radius/medium -
background#171717figure/media
displayflex · align-itemscenter · justify-contentcenter · overflowhidden
caption
-
font-family'General Sans Variable'font-family/base -
font-weight400typography/label/font-weight/regular -
font-size12pxtypography/label/font-size -
line-height14pxtypography/label/line-height -
letter-spacing0pxtypography/label/letter-spacing -
color#999999figure/caption