Figure
A picture or a diagram with its caption, and the same thing told in words for whoever cannot see it. The React twin of the docs' Figure: the same box.
import { Figure, FigureSkeleton } from '@sypnia/ui/react'
A diagram
This diagram in words
The customer places the order in the shop. The shop saves it in the database, which tells the kitchen screen at once.
Code
import { Figure } from '@sypnia/ui/react';
// A diagram with its caption, and the same thing in words behind «This diagram in words».
export default function Flow() {
return (
<Figure caption="How an order reaches the kitchen." words="The customer places the order in the shop. The shop saves it in the database, which tells the kitchen screen at once.">
<svg className="sy-dg" viewBox="0 0 640 120" role="img" aria-label="Shop, database and kitchen, connected left to right">
<rect className="dg-box" x="10" y="30" width="150" height="60" rx="10" /><text x="85" y="66" textAnchor="middle">Shop</text>
<path className="dg-wire" d="M160 60 H240" />
<rect className="dg-box" x="240" y="30" width="160" height="60" rx="10" /><text x="320" y="66" textAnchor="middle">Database</text>
<path className="dg-wire" d="M400 60 H480" />
<rect className="dg-box dg-box--main" x="480" y="30" width="150" height="60" rx="10" /><text x="555" y="66" textAnchor="middle">Kitchen</text>
</svg>
</Figure>
);
} A picture
Code
import { Figure, FigureSkeleton, Image } from '@sypnia/ui/react';
// A picture as a figure, and the figure's skeleton.
const shot = 'data:image/svg+xml;utf8,' + encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="675"><rect width="1200" height="675" fill="hsl(210 25% 90%)"/><rect x="40" y="40" width="1120" height="70" rx="12" fill="hsl(210 25% 80%)"/><rect x="40" y="140" width="540" height="495" rx="12" fill="hsl(210 25% 84%)"/><rect x="620" y="140" width="540" height="230" rx="12" fill="hsl(210 25% 84%)"/></svg>');
export default function Picture() {
return (
<div className="sy-cols sy-cols--stack">
<Figure caption="The orders page after the change."><Image src={shot} alt="The orders page: a header, a list on the left and a chart on the right" /></Figure>
<FigureSkeleton />
</div>
);
} Skeleton
Code
import { Figure, FigureSkeleton, ImageSkeleton } from '@sypnia/ui/react';
// A figure and its skeleton: the picture and the caption.
export default function Skeleton() {
return (
<div className="sy-cols sy-cols--stack">
<Figure caption="The orders page."><ImageSkeleton /></Figure>
<FigureSkeleton />
</div>
);
} When to use it
Use it when
- Diagrams and screenshots that explain something.
wordsalways: screen readers and agents read it.
Do not use it when
- Decoration: use Image with an empty alt.
For everyone
- The figure is named by its caption; the words are behind a disclosure everyone can open.
Props
| Figure | Type | Default |
|---|---|---|
caption | ReactNode | |
labelA name for the figure when the caption is not plain text. | string | |
wordsThe figure in words, behind «This diagram in words». Screen readers and agents always get it. | ReactNode |
| FigureSkeleton | Type | Default |
|---|---|---|
caption | boolean | true |
ratio | string | 16 / 9 |