Currently brewing — dede is in beta: a first set of components, with more to come. The API may still change.

Figure

An image, a video or a drawing, with an optional caption under it and an optional panel behind it.

import { Figure } from "@dede-style/ui/figure", then put your own image inside it: <Figure caption="…"><img … /></Figure>. Figure never draws the image itself, so a plain <img>, Next’s Image, a <video>, an SVG or a component all work.

Placeholder photo: hills and a lake at dusk
Hills and a lake at dusk. A placeholder photo.

A figure fills the lane it is in. Most dede components are only as wide as their content. A figure is different, because an image has no natural width that suits a page. To make it narrower, use fit or put it in a narrower lane.

With caption, Figure renders a <figure> and a <figcaption>, so the caption is tied to the image for screen readers. Without one it renders a plain <div>. The caption is always under the image, or under the panel when there is one.

surface="sunken" puts the content in a panel: a rounded box in the sunken surface colour, with padding round the content. Without it, the content stands alone.

A hero image

No panel. The photo is cropped to 16:9 and has rounded corners.

Placeholder photo: hills and a lake at dusk
<Figure
    contentRatio="16:9"
    rounded
>
    <img src="/hero.jpg" alt="…" />
</Figure>

contentRatio gives the content a fixed shape. An image, video or SVG inside fills that shape and is cut to fit, from the middle. This photo is 16:10, so a little is cut from the top and the bottom.

rounded rounds the content’s corners. Use it for a photo that stands alone. Content inside a panel is square unless you turn it on.

An image with a caption

The same photo at 60% of the width, with a caption.

Placeholder photo: hills and a lake at dusk
The caption is as wide as the image above it.

fit sets the content’s width as a share of the figure: fit={0.6} is 60%. Without a panel, the caption takes the same width and sits directly under the image.

The caption is small text in the tertiary text colour, 12px below the image.

A photo in a panel

The photo at 85% of the panel’s width, with a hairline round it.

Placeholder photo: hills and a lake at dusk
<Figure
    surface="sunken"
    fit={0.85}
    border
>
    <img src="/photo.jpg" alt="…" />
</Figure>

In a panel, fit is a share of the space inside the panel’s padding. The content is centred unless you move it with justify.

border draws a hairline in the subtle border colour. Use it for an image whose own edge is white, such as a document or a screenshot, so its edge shows. The line is drawn over the image, so it takes no room.

A tall document

The panel is held to 16:9. The document starts near the top and runs off the bottom edge.

Placeholder document: a long page of text with a picture
<Figure
    surface="sunken"
    panelRatio="16:9"
    paddingBottom="none"
    fit={0.6}
    border
>
    <img src="/report.png" alt="…" />
</Figure>

panelRatio gives the panel a fixed shape. Without it, the panel is as tall as its content plus its padding.

When the content is taller than the panel, it starts at the top and the panel cuts it off at the bottom. That shows the reader there is more of it. paddingBottom="none" takes away the padding at the bottom, so the document meets the edge.

Showing part of an image

A square image cropped to its top half, sitting on the panel’s bottom edge as if the rest runs off below.

Placeholder square: a white circle on blue
<Figure
    surface="sunken"
    panelRatio="16:9"
    contentRatio="2:1"
    contentPosition="top"
    fit={0.75}
    align="end"
    paddingBottom="none"
>
    <img src="/square.png" alt="…" />
</Figure>

There are two ways to show part of an image. The first is the tall document above: the panel cuts the image off where it ends. The image keeps its own size, and the part you see depends on how big the panel is.

The second is this one: crop the image itself. contentRatio="2:1" makes the image twice as wide as it is tall, so half of this square is cut away. contentPosition="top" keeps the top half. It can also be bottom, start (left), end (right) or center, the default.

Let the panel cut it when the reader should see that there is more, as with a long page. Crop the image when you choose exactly which part shows, and want that part the same at every width.

A wide sheet

No padding at the sides or the bottom, so the sheet runs off three edges.

Placeholder design sheet: a row of screens side by side
<Figure
    surface="sunken"
    panelRatio="16:9"
    paddingStart="none"
    paddingEnd="none"
    paddingBottom="none"
>
    <img src="/screens.png" alt="…" />
</Figure>

Each edge of the panel has its own padding prop: paddingTop, paddingBottom, paddingStart (left) and paddingEnd (right). Each takes a layout spacing step, as a Stack’s padding does, and defaults to step 2. "none" lets the content meet that edge.

dede says start and end rather than left and right, because they swap in a right-to-left language.

A screenshot in the corner

The screenshot sits in the bottom-right corner and meets both of those edges.

The panel has a fixed shape, 16:9. The screenshot is 75% of the panel’s width, pushed to the bottom-right, and there is no padding on those two edges.

Placeholder screenshot of an app
<Figure
    surface="sunken"
    panelRatio="16:9"
    fit={0.75}
    justify="end"
    align="end"
    paddingEnd="none"
    paddingBottom="none"
>
    <img src="/app.png" alt="…" />
</Figure>

justify moves the content from side to side and align moves it from top to bottom. Each takes start, center (the default) or end. Together with the padding props they reach every edge and every corner.

align only shows when the panel is taller than its content, which is when it has a panelRatio. With align="end", content taller than the panel keeps its bottom edge on the panel’s bottom and is cut off at the top instead.

A sketch that stays light

A pencil sketch on a dark page: in the usual panel, and in a panel with mode="light".

Placeholder pencil sketch of a web page
The usual panel: the sketch is hard to see.
Placeholder pencil sketch of a web page
mode="light": the panel stays light.

A sketch, a flow chart or a sheet from a design tool was drawn for a light page and has no dark version. In dark mode its dark lines disappear into a dark panel. mode="light" keeps that one panel light in either mode, so the drawing looks as it was made.

mode works as it does on a Section. It takes light, dark or inverse (the opposite of the page), and it applies to the panel only. The caption stays in the page’s mode.

Spilling out of the panel

A phone screen set at the bottom of a panel that is too short for it.

Placeholder screenshot of a phone screen
overflow="hidden", the default
Placeholder screenshot of a phone screen
overflow="visible"

By default the panel cuts off anything that goes past its edge. overflow="visible" lets the content spill out instead, so here the phone rises above the top of its panel.

Leave room for it. Content that spills out can cover whatever is next to the figure.

A diagram drawn in code

The content here is an SVG written in the page, not an image file.

BriefBuildReview
A flow drawn as SVG. It follows the page’s mode.

Figure takes any content: an SVG, a chart, or a component that draws a screen. An SVG directly inside fills the width, as an image does.

This diagram paints its boxes and text with dede’s colour roles, so it changes with light and dark mode. An image file cannot do that.

A panel colour of your own

A panel in a colour that dede does not have, set by a class in your own stylesheet.

Placeholder screenshot of an app
/* your stylesheet */
.canvas-brand {
    --color-surface-sunken: #d8e2ec;
}

<Figure surface="sunken" className="canvas-brand">
    <img src="/app.png" alt="…" />
</Figure>

There is no colour prop. The panel is painted with the sunken surface role, --color-surface-sunken. Set that role on your own class and give the class to the figure. Only that figure’s panel changes.

The colour here is the same in both modes, as a design tool’s canvas is. dede only checks contrast for its own colours. If you set your own, checking them is up to you.