Rost

← All components

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.

In code Contract: review Guidance: proposed Contract on GitHub Figma 748:28 As markdown
Every component starts as a contract, then becomes code and a drawing.
Default

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

PropTypeValuesDefault
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

  • gap 8px spacing/gap/small
  • margin 0px spacing/gap/none

displayflex · flex-directioncolumn

media

  • border-radius 12px spacing/radius/medium
  • background #171717 figure/media

displayflex · align-itemscenter · justify-contentcenter · overflowhidden

caption

  • font-family 'General Sans Variable' font-family/base
  • font-weight 400 typography/label/font-weight/regular
  • font-size 12px typography/label/font-size
  • line-height 14px typography/label/line-height
  • letter-spacing 0px typography/label/letter-spacing
  • color #999999 figure/caption