Content
Figures
Captioned images with the figure, figure-img and figure-caption classes.
How it works
Anytime you need to display a piece of content — like an image with an optional caption — consider using
a <figure>. Use the included .figure, .figure-img and
.figure-caption classes to provide some baseline styles for the HTML5
<figure> and <figcaption> elements. Images in figures have no
explicit size, so be sure to add the .img-fluid class to your <img> to
make it responsive.
.figureisdisplay: inline-block, so it shrinks to its image and can be aligned with text utilities..figure-imgadds a .5rem bottom margin andline-height: 1..figure-captionis .875em in the secondary text colour — navy-400 in light, navy-100 in dark.
HTML
<figure class="figure">
<svg class="figure-img img-fluid rounded" width="400" height="300" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Placeholder: 400x300"><rect width="100%" height="100%" fill="var(--bs-secondary-bg)"/><text x="50%" y="50%" fill="var(--bs-secondary-color)" dy=".3em" text-anchor="middle">400×300</text></svg>
<figcaption class="figure-caption">A caption for the above image.</figcaption>
</figure><figure class="figure">
<img src="..." class="figure-img img-fluid rounded" alt="...">
<figcaption class="figure-caption">A caption for the above image.</figcaption>
</figure>
Alignment
Aligning the figure's caption is easy with our text utilities.
Because the figure is inline-block, you can also align the figure itself inside a block with
.text-center or .text-end on the parent, or float it.
HTML
<figure class="figure">
<svg class="figure-img img-fluid rounded" width="400" height="300" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Placeholder: 400x300"><rect width="100%" height="100%" fill="var(--bs-secondary-bg)"/><text x="50%" y="50%" fill="var(--bs-secondary-color)" dy=".3em" text-anchor="middle">400×300</text></svg>
<figcaption class="figure-caption text-end">A caption for the above image, aligned end.</figcaption>
</figure><figure class="figure">
<img src="..." class="figure-img img-fluid rounded" alt="...">
<figcaption class="figure-caption text-end">A caption for the above image.</figcaption>
</figure>
With a thumbnail
.figure-img combines with .img-thumbnail from the
images page for a framed, program-paper look. The caption below reads like a
photo credit.
HTML
<figure class="figure">
<svg class="figure-img img-fluid img-thumbnail" width="320" height="240" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Placeholder: 320x240"><rect width="100%" height="100%" fill="var(--bs-secondary-bg)"/><text x="50%" y="50%" fill="var(--bs-secondary-color)" dy=".3em" text-anchor="middle">320×240</text></svg>
<figcaption class="figure-caption">The champion's entrance, Boston Garden, 1991. Photo: house photographer.</figcaption>
</figure>Sass
Variables
$figure-caption-font-size: $small-font-size; // .875em
$figure-caption-color: var(--bs-secondary-color); // navy-400 light / navy-100 dark